The root of the problem, is that the Arduino UNO board cannot behave like a USB HID (e.g. keyboard) while supporting uploading compiled sketches to the microprocessor.
Fortunately, I am not the first Arduino UNO user who has run across this limitation. Better yet, there are several Arduino-savvy power users who have figured out and shared their knowledge with the rest of the Arduino user community.
Here's the gist of the solution: The Arduino UNO board needs to be put into Device Firmware Update (DFU) Mode. While in DFU mode, the Arduino board's USB interface firmware is changed from a USB Arduino programming device to a USB keyboard interface device. While a keyboard device, an Adruino sketch can include sending "keystrokes" to the USB host device such as a PC or Mac.
In the following discussion, I am going to refer to "Programming Mode (PM)" and "Keyboard Mode (KM). These are just terms I have created for the purpose of this description. PM refers to the "mode" where the standard Arduino USB firmware is installed to the Arduino UNO board. PM supports uploading Arduino sketches. KM is the "mode" where your sketch can interface with you computer as if it were a standard USB keyboard. The fore-mentioned DFU mode is a more commonly used term that we will recognize as an intermediate state required to "toggle" between these other two states.
So the programming sequence goes like this:
- Connect a USB cable to the Arduino UNO board.
- The original Adruino UNO board starts in "Programming Mode (PM)". So, to start, compile and upload your "Keyboard Mode (KM)" sketch the same way you would normally for non-KM sketches.
- Put the Adruino board into DFU Mode. This is a 2-step process:
- First, you must connect two points of the Adruino UNO board to ground.
- Next, use the "dfu-programmer" command to set the Adruino into DFU mode and upload the keyboard firmware (Arduino-keyboard-0.3.hex) file.
- Unplug the USB cable to remove power.
- Plug-in the USB cable. The KM sketch will begin to run.
For details, please refer to [solved] DFU Mode Arduino UNO without soldering.
The process is similar to going from PM to KM,except that this time the "dfu-programer" command is used to upload the PM firmware (.hex) file:
- Connect a USB cable to the Arduino UNO board.
- Put the Adruino board into DFU Mode. This is a 2-step process:
- First, you must connect two points of the Adruino UNO board to ground. (Same as before.)
- Next, use the "dfu-programmer" command to set the Adruino into DFU mode and upload the PM firmware (Arduino-usbserial-uno.hex).
- Unplug the USB cable to remove power.
- Plug-in the USB cable. The KM sketch may begin to run, but no keystrokes will be sent to PC or Mac.
EDIT (Months later): I never quite finished this blog entry. Sorry dear reader, but I moved on before really putting together the kick-ass USB game controller that I'd originally intended. Brainstorms sometimes do that. They come, then go. Despite this, I've decided to publish what I figured out As-Is to help some aspiring hacker to perhaps carry on from where I left off. Or I may pick it up again in the future.
No comments:
Post a Comment