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.

22 thoughts on “USB Keyboard Becomes an AVR Programmer

  1. 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.

    1. 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.

  2. I don’t really see the use of the de-bouncing here as there are no physical buttons. can someone explain this to me?

    1. 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)

      1. Oh yes, I didn’t read the website itself. Because I was wondering “why the hell would he be debouncing digital signals” in the first place.

  3. Wow I had the same idea, never got around to making it happen. I even have the pcb as shown. Kudos for making it happen and not forgetting about it.

  4. Depending on the hardware, he might be able to have the circuit cascade into pushing another button that the driver doesn’t listen to in order to get around the debounce.

    1. Because it needs extra hardware? I don’t see why not, but I don’t see what the advantage would be, as the keyboard already has the input and output that it needs.

  5. 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!

  6. Someone should make a variant of this that uses the integrated sound IC on most laptops as a programmer/reader using a mic and both L and R channels.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s