Arduino based Human Interface Device

Part 1

Originally published at on August 5, 2010.

This summer I have been tinkering with my Arduino micro-controller and recently bought Wii Nunchuck in a quest to create a Wii Nunchuck based HID for playing games. Since the beginning of summer I have tried many different methods for doing so and here are some advantages and disadvantages of each:

AAC keys (

This software is excellent and hassle-free for sending keypresses to your computer. You just have to use a command from your Arduino sketch such as Serial.print(“\033left.”); to send a keypress (in this case left arrow button). However, the disadvantage of using AAC keys is that keys are pressed and released. There is no way to press and hold down any key other than Shift, Ctrl and Alt. This isn’t good for playing games where you usually need more than three keys.

Gobetwino (

Another great software that allows you to do a bunch of useful stuff such as opening/closing programs, sending emails, and sending keypresses to programs from your Arduino. It is also well documented. However, I had problems opening some games and holding down keys.

This method really worked well as I could hold down and release keys whenever I wanted to and worked with most games. I simply added this class to my Processing sketch in three lines:

import java.awt.AWTException;
import java.awt.event.InputEvent;

Created an object of the class: Robot ricky
And generated key-downs, key-ups and mouse mouse movements:


And my Arduino program sent the data from the Wii Nunchuck to the Processing sketch.

However, this method did not work with some older games on compatibility mode, and definitely would need some tweaking to make it work in different computers (like installing Arduino driver and Processing).

Thus, my final attempt was to make a truly plug-n-play Arduino based “adapter” that would allow me to hook up my Wii Nunchuck and play games with it on any computer, on any games, in any OS. So I used the PS2dev library from the Arduino playground (

which allows you to let the Arduino emulate a PS/2 device. I wrote a code for emulating a PS/2 keyboard and it works great :D. Now you can play Paratroopers (image below) on your old IBM pc using the Wii Nunchuck over the PS/2 protocol or hook it up to your Altera DE2 for whatever you can think of ;)

As for me, I connected it up to a USB to PS/2 converter to play games. The pins 3 and 4 of the PS/2 port powers the Arduino :) Here are some pictures of my build:

The joystick generates W,A,S,D based on position. The accelerometer roll and pitch generates I,J,K,L. The z-button generates Spacebar and the c-button generates Shift. Good enough for most games :) Mouse positions can be controlled using numpad keys in most OSs so thats not a problem either :)

I will be posting my code and a video for you to enjoy in my next blog-post. I hope this article is useful for all Arduino fans interested in making their own custom HIDs over the PS/2 or USB ports.

Originally published at on August 5, 2010.