Arduino Keyboard Emulator *Updated*

On April 28, 2011, in Electronics, by Vlad Cazan

At the EDGE Lab in the Digital Media Zone, we are trying to design a custom keyboard for children with disabilities in order to make typing more exessable. Many of the children simply cannot work a standard US keyboard. The buttons are too close, the buttons are too hard, or the layout is really confusing for children. These are many of the complaints we got so we attempted to build our own custom keyboards.

A few months ago a new line of arduino micro controllers came out called UNO and MEGA 2560. They included a new ATmega8U2 chip which was flashable. This ment that you could change the code on the chip and make the USB port resister as something different then an arduino. Using this chip I was able to get a keyboard hid firmware onto the ATmega8U2 and when I plugged it in my commuter it recognized it as a plug and play keyboard. I am still able to flash the mega chip using a ISP programmer.


Then using the schematic  of a button from arduino.cc I was able to create a small sketch that wrote the letter a to the computer whenever the usb was plugged in and the button was pressed. Creating a full keyboard is as simple as adding more buttons.

Attached are the hex files for the ATmega8U2 for both the UNO and MEGA 2650 as well as a demo sketch to get you started. I will post the final code for the keyboard when it is complete.

Arduino Keyboard Emulator


Arduino-keyboard-0.3
Title: Arduino-keyboard-0.3 (3294 clicks)

Caption:

Filename: arduino-keyboard-0-3.hex

Size:

Arduino-keyboard-0.3-mega2560
Title: Arduino-keyboard-0.3-mega2560 (2751 clicks)

Caption:

Filename: arduino-keyboard-0-3-mega2560.hex

Size:

arduino-keyboard-0.3.tar
Title: arduino-keyboard-0.3.tar (3139 clicks)

Caption:

Filename: arduino-keyboard-0-3-tar.gz

Size:

kbd_usb_demo
Title: kbd_usb_demo (3730 clicks)

Caption:

Filename: kbd_usb_demo.pde

Size:

*UPDATE*

In the last few months the EDGE Lab has been working very hard building this custom keyboard. Our final goal is to create a mobile wearable vest that can be worn. It will include a speaker for voice, and a custom screen for visual display. Currently here are the pictures of our prototypes as of September 2011. Feel free to comment if you have any more question about how you can make this for someone with disabilities.






Tagged with:  

47 Responses to “Arduino Keyboard Emulator *Updated*”

  1. Pete says:

    Hey! NIce going! I’m working on a similar project and I’m having trouble with getting an Arduino UNO to show up as a USB keyboard. I have no idea how to flash the board and use the .hex files. Could you show/tell me how to do this?

    • Vlad Cazan says:

      Thanks. There are two options when flashing the at90 chip on the arduino. First you need to remove the solder from the 6 holes beside the chip. Using a solder sucker just clean it up and put a 3×2 header in it’s place. You can put the chip in DFU mode using the instructions in the zip file or you can just write to it using an AVR programer . I have this one from sparkfun and it works great. http://www.sparkfun.com/products/9231

      The advantages to using an avr programer is that you can flash and arduino chip while the at90 is still a USB host. Let me know if you need anything or email me at Cazanv @ gmail.com

      • Pete says:

        Wow, thanks for the tip! However, I’m afraid I don’t really have easy access to any soldering equipment. Right now I’ve set my sights on using a Teensy like this guy does: http://blog.makezine.com/archive/2011/04/the-awesome-button.html

        It seems a Teensy board has USB-Keyboard recognition included, but it sounds almost too good to be true. What was your reason to choose Arduino over a Teensy?

        • Vlad Cazan says:

          To be honest I have never used a Teensy board before. I tried to order one last September but after 2 months I had to cancel my order because they were out of stock. I guess that is one reason I picked the Arduino, they are very cheap (almost as cheap as the Teensy) and you can use the arduino for far more applications they you can with the Teensy. There is also a lot more support and sample code written for an Arduino.

          I really liked the fact that I could program the usb chip on the arduino to act as a mouse, a keyboard a joystick or any other HID regulated device. Using the LUFA drivers from Four Walled Cubicle you can turn the arduino to any of these devices.

          Audio In Device
          Audio Out Device
          Dual Virtual Serial Device
          Generic HID Device
          Generic HID Host
          Joystick Device
          Joystick Host
          Keyboard Device
          Keyboard/Mouse Device
          Keyboard Host
          Keyboard Host/Device Dual Mode
          Mass Storage Device
          Mass Storage/Keyboard Device
          Mass Storage Host
          MIDI Device
          MIDI Host
          Mouse Device
          Mouse Host
          Printer Host
          RNDIS (CDC) Ethernet Device
          RNDIS (CDC) Ethernet Host
          Still Image Host
          Virtual Serial Device
          Virtual Serial/Mouse Device
          Virtual Serial Host

          If all you are looking for is making a plug and play keyboard then maybe it might be simpler to use the Teensy as you probably wont need to solder anything. But soldering is fun and a solder gun is $10 – $15 so its not a big deal.

          • Pete says:

            Valid reasons : )

            I received a Teensy yesterday and programmed the rough functionality I was looking for in about an hour. It’s limitations are starting to show up now though, not all the Arduino-ish code seems to work for a Teensy.

            Anyway, thanks for the tips and good luck with your project : )

  2. Jonas Arvidsson says:

    Hello! Im just woundering about your progress. I have a paralized friend who needs a 12 button keyboard to play World of Warcraft! =)

    Great job! =)

    • Vlad Cazan says:

      Work has ben going quite well. We have finnished two prototypes, one with fabric buttons which will be made into a wearable vest, and another one with arcade style buttons. I can for sure give you some advise and programming help if you would like to build one for your friend.

      Check out the pictures i’ve added to the post for an update and ideas.

      • Jonas Arvidsson says:

        That would be great for sure! Funny about IMG_0141.jpg, thats more or less the design Im going for! 🙂

        Some questions:

        • Do I need the SMD version of the UNO board to get it to show as a HID Keyboard?
        • How do I flash the board so it show up as a HID device?

        Thanks =)

        • Vlad Cazan says:

          Any version of the arduino will work. You need to flash the atmega8u chip via the ISP headers on the board. You will need a pocket avr programmer or another arduino to flash the chip. The hex file is in this post. After that you just edit the sketch in the post for the buttons you want / need.

  3. […] a great chat with Jason Nolan about the work EDGElab is doing in assistive design. He showed me an Arduino-based keyboard emulator designed by Vlad Cazan that was built to help a young girl with 1P36 deletion syndrome to […]

  4. […] a great chat with Jason Nolan about the work EDGElab is doing in assistive design. He showed me an Arduino-based keyboard emulator designed by Vlad Cazan that was built to help a young girl with 1P36 deletion syndrome to […]

  5. Jose says:

    Hi Vlad.. is there any documentation on this on how to send keys to the computer the sketch is kind of confusing for a begginer like me

  6. Nam says:

    I make keyboard by Atmega8u2 via USB from your code, but I don’t sent data in Word. I need your help
    Thank!
    Nam Pham.

  7. maldine says:

    Hello !

    I am starting a similar project to use the arduino as a keyboard to emulate a custom controller.

    I was wondering if your design allows for multiple key press, and if yes, how many simulaneous keypresses ?

    Update : just read through the HID document, seems like 6 simultaneous can be sent (+ 1 modifier), is that correct ?

    Thanks for your help!

  8. Robert says:

    Hi Vlad,

    this is just what I need! but I am a little confused about what happens when I flash my arduino UNO with your .hex file. Can I then still upload arduino code to it or how does this work?
    And you mention that you can use another arduino to flash the chip, do you have any more information on how to do this?

    thanks!

    • Vlad Cazan says:

      Hey Robert,

      You will need to flash the at90(the chip beside the USB port) with either another arduino or a pocket programer.

      I prefer to use a programer to avoid the hassle of setting up another arduino and I use this one here http://www.sparkfun.com/products/9825

      If you would like to program it yourself with another arduino you can follow the tutorial here: http://arduino.cc/en/Tutorial/ArduinoISP

      After you flash the chip you will no longer be able to program the m328p without a programer or another arduino.

      The easiest way to do it would be to upload the keyboard sketch to the m328p then use a programer or another arduino to program the at90.

      Let me know if you need any help I’ll be glad to help you get it working.

  9. Robert says:

    thanks for the quick response! I actually managed to get hold of an avr programmer, but how to connect to the headers of the arduino? To aref or icsp and how do I know its not connected in the wrong direction? And do you have a good ISP programmer software?

    • Vlad Cazan says:

      You use the ISP headers beside the reset button. Plug it in one way, see if the lights light up and if they do its the right way, if they dont then flip it and it should be fine.

      I have been using AVRdude for writing files to my programmer. You can use the command below after installing AVRdude to send a hex to the atmega328p:

      avrdude -c usbtiny -B 1 -patmega328 -U flash:w:main.hex

      just replace main.hex with the name and location of your hex file…hope that helps!

      • Robert says:

        ok the first part I managed 🙂 but where or in what program do I type that command? And where should the .hex file be?

  10. Steve L. says:

    Vlad,

    I am creating a keyboard emulator using the Arduino Nano v3.0 from Gravitech and I followed your instructions to the letter but have failed to make the Nano appear to the PC as a keyboard. I am not sure that the hex file that you provided here is correct for the Nano and I have no idea how to create a hex file that excludes the boot loader. I would appreciate any help you can offer.

    Thanks, Steve

    • Vlad Cazan says:

      Hey Steve,

      Unfortunately you cannot create a keyboard emulator using the nano. It uses a FTDI chip that cannot act as a HID device. For this to work you will need a newer arduino which uses Atmega8U2 as a usb interface.
      Sorry about that.

      Vlad

  11. Daniel says:

    hi Vlad,

    I’m trying to make a arcade controller, using buttons and started from the example code you have, but when I press the buttons it seems that the codes get sent, but not interpreted( by my PC) as the codes i programmed on the arduino,
    I can send the code your side if you would like to have a look.

    The example code works great, sending “Hello World” from the arduino, but does not seem to play along when used with button presses.

    did you have similar issues ?

    I’m using Ladyada’s code for scanning button presses (http://www.adafruit.com/blog/2009/10/20/example-code-for-multi-button-checker-with-debouncing/ )

    Regards,
    Daniel

  12. Alex says:

    Sweet post, thank you.
    I am looking to find a way to interface a 12 button keypad with a computer via an arduino uno (or whatever other chip needed to make it work). I have found some people online that have done similar projects, I think that I will just need to build the keyboard and program it. I am thinking the best way to do this is to modify the following:
    http://www.vladcazan.com/previous-projec…d-emulator

    I found some good code that will help me make it so the buttons act as an old nokia phone’s input:
    http://code.google.com/p/multi-tap-keypad/

    I would like the 12 button keyboard to act just like an old Nokia phone’s input.

    I spent 3 years in Mozambiuqe, Africa and the reason I am doing this is because many in Africa can’t type, but they can type on Nokia phones amazingly well. This would help many get jobs in Mozambique and they would be able to overcome the single greatest barrier to them using computers, which is the keyboard. Anyway, I would want it to be an open source kind of project.

    Any ideas? Suggestions? willingness to help me out a little bit? THANKS! Cheers.
    -Alex

  13. Kir says:

    Hi Vlad,I’m trying to make your own keyboard
    at arduino but I do not quite understand how you brought with him a letter, because in the demo do not have this, could you please put an example of its program? or give an explanation of how to describe the right keys?
    thanks in advance =)

    • Vlad Cazan says:

      Each button has a hex code which if you send to the serial buffer will send that letter to the computer. I can post a demo of the keyboard we have at the lab.

  14. Kir says:

    That is, I realized, just by pressing the keys sent to the clipboard by serial print, a hex code of button?)

  15. James says:

    Hello! there are a couple of problems with the output data at a time of 5 characters is printed, can you help?

  16. Mackaber says:

    Just notice, the USB Usage tables are no longer in the original document, they have been moved here… http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf

    Also, I used your project to make a “Teensy-like” Attack vector, typing commands in a windows shell, so… Thanks for sharing this 🙂

  17. Lizino says:

    Hi Vlad,

    I’m not sure if you have to prove the comments before they are posted but i think that what you are doing is great, its awesome that we can help people trough technology! I’m working on a similar project, I want to activate actuators for a braille cell to activate with each key press but i’m having trouble finding out how to get “inside” of the look up table (i don’t thin I can since it is in hex ?) or how to develop my own look up table. Do you have any suggestion or a suggestion of a place where I can learn more about this?

  18. Jimmy says:

    Hey i wanna know how to flash an arduino uno cause i am a little bit comfused on that part of it.i saw somthing about putting a wire between ground and reset.

  19. klaus says:

    Hi Vlad,
    this is a great project!
    I would like to build a similar device, but using the arduino as a PS/2 keyboard with a few defined buttons. like “s”, “u”, “n”.
    Is it possible to rewrite your code from usb to serial?
    Thanks
    Klaus

  20. Leonardo says:

    Hello, very good job, now I am unable to make the program, I Might you spend sketch already done? thank you very much

    PS: I modified it .. Congratulations
    If you sends me to my email

  21. Jayant says:

    Where is the link to the code?

  22. Mike says:

    Hi. Thank you for sharing this imformation. I have a question please. I have programmed my Arduino UNO to work as a keyboard, I have build a small matrix and each button will display a number when I press it. but the thing I don’t understand is that how can I use this keypad to type the numbers in any program. like I can type the numbers in notepad or ms word. they only place I can type the numbers is the Adruino IDE.

Leave a Reply

Free WordPress Themes

Page 1 of 1 1

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

Highslide for Wordpress Plugin WordPress Themes