USB Keyboard Becomes an AVR Programmer

[Steve] created an AVR programmer using an old USB keyboard. We feature a bunch of AVR programmers, but this one is made from parts that many people will have lying around. There are two components: the controller PCB from a USB keyboard, and an optocoupler for emulating key presses.

In order to send data to the AVR, [Steve] used the LED outputs on the keyboard. These LEDs can easily be toggled according to the HID device specification. They provide a 5 volt output with current limiting resistors, which means they can be connected directly to the target AVR.

Reading data is a bit more complex. The optocoupler tricks the keyboard into believing that a single key has been pressed, firing off a data transfer. The MISO pin on the AVR is connected to the row and column of the shift key, which is read by the driver.

On the software side [Steve] created an avrdude interface driver. This allows the programmer to be used with avrdude, just like any other programmer. [Steve] does point out that it isn’t the fastest programmer since the keyboard tries to debounce the MISO input, greatly limiting the speed. However, since it’s made from stuff you might have in your junk bin, it’s a neat hack.

Post navigation

22 thoughts on “USB Keyboard Becomes an AVR Programmer”

I did something similar as a school project – transfer of image data bit by bit using the keyboard LEDs. The USB device was a pSoC.. basically what I found was that the keyboard leds are not a reliable data transfer device, at least on Windows.

Did you communicate directly with the keyboard, or was the operating system’s HID driver doing the job? Since I unload the kernel driver and access the keyboard from userspace, that works fine and very reliable. Also this doesn’t interfer with the state of the ‘real’ keyboard attached to the machine. On Windows this should work by removing the default HID driver in the device manager, and using zadig to bind the generic libusb-driver to the device.

The keyboard controller does it because it was designed to read mechanical buttons. I also believe the speed is limited by how fast keyboards transfer types to the computer(you cannot really type that fast but for a microcontroller…. that’s slow)

This actually inspired me to create a little gadget for my girlfriend. She was suffering lack of num-section in her laptop, so I bought one of those USB numerical keyboards with USB hub. I split it apart and packed tiny-attiny13 and entrails of an old pendrive inside. AVR listens to what num-lock diode says, and depending on what it is (no, I am not going to tell you the secret sequence), enables pendrive power line via transistor. In order to achieve thrilling impressions in user, there are also few red smd leds blinking&shining through holes drilled in a special shape on the top of the keyboard case. All of those cheap USB devices seems to be so hackable!