Cheap Joystick and Accelerometer for Arduino from Wii Nunchuck | RF Circuits

Friday, July 1, 2011

Cheap Joystick and Accelerometer for Arduino from Wii Nunchuck

For ages now I've been wanting to play with an accelerometer but didn't really fancy paying £20-25 for the privilege. I'd also seen a lot of posts about people using the joystick from a Wii Nunchuck to control robots, servos, cameras, etc, which I didn't have a lot of interest in. Then I remembered that the Nunchuck controller actually has an accelerometer built in. Long story short, I'm now short one Nunchuck and plus one accelerometer.

The economics of this one really work out, since a Nunchuck is usually only about £15, and communicates over I2C which saves on IO. So far, the lowest price accelerometer I've found was over £20 and communicated using 3x analogue signals.

Obviously I'm not the first to make this realisation. A quick Google search took me to http://www.windmeadow.com/node/42, which gives a great tutorial on how to wire it up and gives a sample sketch to get you up and running.

I wanted a way to visualize the data coming out, just so I could see how it looks when I make a few gestures or use the buttons and joystick. I'm not the greatest fan of Processing (mainly because I haven't used it an awful lot) but I am a big fan of Java. I created a program which shows me the current levels of each of the 5 axes (x, y, z, joystick x, joystick y), and the 2 buttons. It also graphs the xyz-axes over time. Cool eh?


As with most of my programs it needs a lot of attached Jar files, so here's my Eclipse workspace folder in zip format.
Note:
you'll need to tweak the Windymedow sample sketch a little to work for my Java program - specifically you'll need to change the value separator in the "print()" function to a comma, not a tab.

No comments:

Post a Comment