Can a USB keyboard be used to control a project running on Teensy 3.1?

Status
Not open for further replies.

kig

Active member
Sorry if this is a noob question, but I have seen a LOT of information about how to use Teensy as a USB host: where it takes over keyboard and mouse of a computer, or controls other hardware via USB.

However, what I'd like to do is to have Teensy be connected to a USB input: I will use a wireless USB keyboard to send data to the software running on Teensy, and thus remotely be able to do all sorts of things. This is for a project related to SmartMatrix and Aurora software that I am working on right now.

Any ideas on how to do that?

Many thanks!
 
Well you might want to hook up with xorian who posted this about the beginnings of a USB host thread: https://forum.pjrc.com/threads/2894...play-spi4teensy3-h-vs-SPI-h?p=75974#post75974.

However, I suspect the simplest path is to not use a wireless keyboard, but instead use a smartphone/tablet with bluetooth support for the data input. Then you would use one of the various bluetooth chips out there to interface with the Teensy (either classic bluetooth 2.x for most Android phones or BLE 4.x for Apple phones and some new Androids) that provide a serial interface that you would hook up to one of the 3 serial ports on the Teensy. In looking for boards, you want one with serial port support, and that can be hooked up to 3.3v without a level converter.

I bought an HC-05 bluetooth board from the ebay seller nyplatform, and I can use several different bluetooth apps on my Samsung Galaxy S2 (Hercules) to interact with the Teensy (though I must admit, I've only done a few simple tests with it): http://www.ebay.com/itm/HC-05-Bluet...ter-Module-Wireless-Serial-6pin-/221605869160.

Bluetooth apps include:

Unfortunately, nyplatform doesn't seem to sell BLE devices. However, Adafruit does sell one: https://www.adafruit.com/products/2479 that is rather more feature packed than the low end board I have. It has the power of a Teensy-LC (Cortex M0) driving the bluetooth chip. They also provide an app for communicating to the device. However if you have an Android that pre-dates 4.3, you probably can't use BLE (bluetooth low energy).
 
Last edited:
It's a technical quibble, but it may save you some grief in the future, but what you see are many examples of Teensy as a USB _device_. The computer which uses the Teensy as a mouse or keyboard is a USB _host_. All computers are devices, of course, and most of them host various things, but when you talk about USB _devices_ and USB _hosts_ you need to get the gender correct or you'll never make head or tail of what you find.

So you're asking if the Teensy can act as a USB _host_ to a USB wireless keyboard, and the answer is that that would require the Teensy to implement USB-OTG (On The Go) which allows a USB port to reverse its roles from _device_ to _host_. And the answer is no, the Teensy doesn't do that, the processor in the Teensy 3.0 and 3.1 could do it if it were wired up differently and had different software on it. In fact, here's the software, https://forum.pjrc.com/threads/28173-Teensy-3-x-NATIVE-USB-HOST-PREVIEW-AVAILABLE, released just 3 months ago. The wiring issues (power supply) are mentioned there, as are the problems people are having with the code. But that in itself is not enough to solve your problem, because acting as a USB _host_ is only the first step in implementing the driver to support any particular USB _device_, and it sounds like the Teensy USB _host_ has implemented the driver for some flavor of Block Storage USB _devices_ so far.

As MichaelMeissner said, you can make a remote controlled Teensy by hooking it up to a Bluetooth serial transceiver and controlling it from a phone or tablet with Bluetooth.

Another possibility would hook the Teensy USB up to an Android phone with an OTG port as a Serial USB _device_ and control that with a Bluetooth keyboard. Or over WiFi. Or over the phone network. There are a lot of instructions floating around about how to hook up android and arduino, and you can check a phone for OTG support with an OTG adapter cable and a USB thumb drive. Not as cheap as the raw bluetooth adapter, but it goes together with off the shelf parts and cables.

Note that very few Bluetooth adapters achieve their claimed range, so don't plan on getting too far away until you've tested how far it actually works.

-- rec --
 
Status
Not open for further replies.
Back
Top