Arduino Nunchuk Integration

by paulware in Circuits > Arduino

1466 Views, 13 Favorites, 0 Comments

Arduino Nunchuk Integration

wiinunchuck1.jpg

For the sumobots class found here...

The Wii nunchuk is a pretty amazing product.

For less than $3.00 here, you can purchase one and have it mailed to your door.

Not only do you get the normal joystick (left,right,up,down), there are also 2 buttons to read. There is also a built-in accelerometer (not covered in this instructable).

Prepare the Nunchuk for Reading

Wires.jpg

To get started, cut the wire near the connector and strip the white, red, green and blue wires.

The nunchuk uses a special protocol called I2C which allows it to communicate with the wii-mote. We won't use the wiimote. Since the arduino nano supports I2C, we will connect the nunchuk directly to the nano.

After stripping the wires, solder each lead to a female header, in this order: (white, red, green, blue). The black wire is not used.

Connect to Pcb

pcb.jpg

Once your leads are soldered to the female header, connect the 4 wires to a corresponding male group of 4 headers. See the photo for the proper orientation.

Upload the Sketch to Read the Values

nunchuckNano.jpg

Now connect the pcb to the nano. Check the photo for the correct orientation.

The attached ArduinoNunchuk.zip file contains a directory called ArduinoNunchuk. This directory should be placed in the arduino libraries directory.

A normal installation of Arduino is located in the Documents/Arduino directory. Inside of this directory is a libraries directory. The ArduinoNunchuk directory found above should be placed in the Documents/Arduino/Libraries directory. After this is done, open the NunChuck.ino file in the Arduino integrated development environment (IDE). The NunChuck.ino should now compile.

After you have compiled the NunChuck.ino sketch, connect the nunchuck to the nano pcb and upload the sketch to your nano.

It will start printing values of X,Y,c button and z button values