HID/USB Keyboard Repeater with Playback
Video Demo:
Quick Links:
Arduino UNO Sketch Code
USB Host Shield Library 2.0
DFU Programmer Source Code
USBSerial Hex File
HIDKeyboard Hex File
To make this, all you need is the following:
- Arduino UNO (preferably R3)
- You can buy one here: http://www.robotshop.com/ca/arduino-uno-usb-microcontroller-rev-3-3.html
- USB Host Shield 2.0
- A very useful shield for the Arduino, it pretty much lets you interface with all USB devices (here the keyboard).
- You can get one here: http://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino
- USB/HID Keyboard
- USB Keyboards are an example of a HID (Human Interface Device), if your keyboard uses USB, it’s very likely HID.
- Two switches and two LEDs (plus the needed resistors; I will assume you know how to use switches/LEDs)
First Step: DFU
I have tested this on Ubuntu 12.04, and do not use any other OS, so I can only give you instructions for such.
Here is the link to the official site on DFU with the UNO (but be warned, if you have R3, it’s out of date).
Link to Arduino DFU Stuff
For those rocking Ubuntu:
First step is getting the DFU programmer code (to be compiled) HERE
(and ALSO get these two hex files: SERIAL and HIDKeyboard).
Unzip the dfu source to:
~/Documents/sketchbook/HID_Keyboard_Repeater/DFU_Source/
and put the hex files in
…/HID_Keyboard_Repeater/HEX_Files/
Then follow the readme directions to install DFU and test
(Please note that every time you reset the DFU, you should plug-cycle the UNO board).
*To put the UNO into DFU mode you need only short the two exposed headers closest to the USB slot*
After testing, put the UNO back to normal (i.e. reseted / plug-cycled / and with USBSerial.hex uploaded), this should be the same as a fresh UNO.
Step Two: USB Host Shield:
After buying and assembling (super easy to assemble), all you need are the libraries. Unzip THIS compressed folder into your …sketchbook/libraries/ folder, so you end up with libraries/USB_Host_Shield/
Step Three: Program and enjoy
- With the UNO not in DFU mode and with the serial hex file uploaded to the 16u (so basically from a fresh UNO).
- Use the regular IDE to program the UNO with the sketch: HERE
- Put the UNO into DFU mode and use the dfu-programmer to upload the keyboard hex file and reset
- Plug-cycle
- Plug in the switches so that REC->LOW@D2, Play->HIGH@D3 (details in the code)
- Plug in the LEDs (details in the code, and additional pics later in this post).
- Enjoy:
- Demo shows how to use, but the code is also very simple.
For reference, here are some pics of my implementation: