Sunday, May 04, 2008

Improvements to Arduino Wii Nunchuck connection

I'm working on an Arduino based controller for an electric canoe. In the process of doing that, I've been looking more closely at the data coming off the wii Nunchuck. Using the avr math libraries, and the atan2 function, you can combine the data from the X and Z accelerometers on the nunchuck to get a nice smooth 360 degrees of roll information. Because this is using an inverse tangent function, it also makes for more accurate angular data than the raw data coming off the device.

Here's a quick demo video, followed by links to the code.

I posted all three files needed for this on the Arduino Playground.

For hardware setup, Todbot's little adapter is the best.

ps. For this same canoe project I wrote up a library for the Wii Classic Controller as well. For anyone interested, that's available here.

George's asks a good question in the comments. If you try and run the code posted on the arduino playground. It's important to note that the third chunk of code needs to be run from the processing application, available here at