USB Host: Keyboard

13 Jan 2012

There are a couple of pages here about using the mbed as a keyboard (ie. a USB HID) but is it possible to plug a USB keyboard into the mbed and read the keys pressed? (I have the workshop breakout, so there's a USB A socket already hooked up)

Thanks!

13 Jan 2012

Hello, yes You can use http://mbed.org/users/peterbarrett1967/notebook/blueusb---bluetooth-and-usb-host-controller-for-mb/ USB host for keyboards, mouses, hubs, flashdisks, cheap $2,- bluetooth dongles and more from Peter Barrett. There is need for pull-down 15K resistor for each D+ & D- USB lines to get USB port operated as USB Host. So if You are using workshop board, there must be some kind of jumpers which You define mbed's USB port to be USB Host or USB Device.

When using USB host program from Peter Barrett You will see reports from keyboard displayed on terminal on Your PC. The report is as keyboard sends it. Format of typical HID keyboard is 8 bytes in length in this format:

/

Byte no. ..... Offset in AUTO_KEYBOARD array .................... Function

1 .................................. 0 ....................................... Modifier keys like CTRL, ALT, etc..

2 .................................. 1 .......................................... Reserved (no use now)

3 - 8 ............................ 2 - 7 ............................... Key Code (1 - 5? simultaneously pressed keys)

/

Every report which keyboard sends is stored in auto_keyboard array.

I hope this can help You.