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.

Comments

  1. solhsa says:

    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.

    • Steve M. says:

      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. Aryl says:

    And they laughed at me when I said not to throw those old keyboards out…

  3. Justin says:

    One of the most original hacks I’ve seen.

  4. biozz says:

    WOW i never even can remotly pretend i thought of this one! very nice!

  5. Tactical Ninja says:

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

    • Bogdan says:

      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)

  6. Spacedog says:

    badass hack. nice pick hack-a-day

  7. kmmankad says:

    and _these_ are the kind of hacks we should be reading about.

  8. Addidis says:

    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.

  9. furan79 says:

    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.

  10. Spitzi says:

    This solves the egg or chicken paradox for building an own USB-AVR Programmer.

  11. Rip Ripster says:

    Congrats! Your HackADay has been featured at Reddit. BEST USE of a rubber dome controller YET!

    http://www.reddit.com/r/MechanicalKeyboards/comments/13vjj3/best_use_of_a_rubber_dome_keyboard_yet_use_the/

  12. hboy007 says:

    Why not use a usb mouse as a return channel?

    • TacticalNinja says:

      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.

  13. domyslnik says:

    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!

  14. too goood plz improve it more and more

  15. BotherSaidMayans says:

    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:

WordPress.com Logo

You are commenting using your WordPress.com 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

Follow

Get every new post delivered to your Inbox.

Join 94,561 other followers