Wii Nunchuck as general purpose controller via Arduino board

Background:

I made a self-balancing electric skateboard which is steered using a Wii Nunchuck by either using the thumb joystick on the top or by tilting it left or right, depending on which of the two buttons on the end are being pressed.

A simplified self balancing board is described in the instructable here:
www.instructables.com/id/Easy-build-self-balancing-skateboardrobotsegway-/

However people are asking me how the Nunchuck steering control used on one of my earlier boards can be used.
The wired Nunchuck can be seen in use as a steering control in the second half of this video:
www.youtube.com/watch

It can also be seen in use controlling a set of LED’s attached to the Arduino ouputs here:
www.youtube.com/watch

I have another instructable on interfacing a wireless Nunchuck to an Arduino but that is quite tricky and only works with a few specific wireless nunchucks. If starting out I strongly suggest going for the wired standard Nunchuck to begin with as described here.

Purpose:

The purpose of this instructable is to describe how to interface a completely standard Wii Nunchuck (i.e. with a cable) with an Arduino board. The Nunchuck is low cost but powerful with a fully proportional thumb joystick, 2 buttons on the end and a 3 axis accelerometer (position sensor). It is ideal for controlling things with.

The Arduino has been set up to output variable voltages between 0 and 5V which can be used as, for example, steering control inputs for another project such as a robot. You can use the (proper propotional) thumb joystick or the embedded accelerometers (tilt the chuck left right forward or back).

By modifying the code you can easily make it do other things.

I am using an Arduino with a 328 processor (i.e. a recent one) and version 17 of the Arduino software.
The Arduino sketch is attached below.

This is all derived from code developed by Chad Phillips and others, see:  http://windmeadow.com/node/42
For more info on wiring up the chuck to the Arduino, download Bionic Arduino Class 4 tutorial which is excellent from TodBot blog:
http://todbot.com/blog/2007/11/24/bionic-arduino-class-notes-3-4/

There is plenty more on this on the net, there is even someone with a Nunchuck controlled electric canoe here:
www.youtube.com/watch

I am just presenting this all together in one place as a way to get started with something that should work OK.

Step 1: View of Nunchuck buttons

Here are the “c” and “z” buttons on front of the Nunchuck.

Step 2: Arduino board inputs and outputs

Outputs:
The outputs from the Arduino are arranged as follows;
Digital Pin 9: outputs +5V when either of the end buttons are pressed. This can be used as a go/stop control signal. If controlling a vehicle / robot or similar, then letting go of the Nunchuck will create a 0V at this output and so can be used to kill power to motors and so on.
Digital Pin 10: PWM (pulse width modulated) output on pin 10 gives 2.5V most of time. NOTE: This is not a smooth 2.5V but a series of pulses at 500Hz where half the time there is 0V and half the time there is +5V. If you smooth them out using a resistor and a capacitor (called an RC filter) you can use the resulting (now smoothed) voltage as a control input signal for some other device (another arduino or whatever).
Output is 2.5V when joystick in neutral position.
It climbs to +5V or drops to 0V when joystick moved forwards or backwards.
Digital Pin 11: PWM (pulse width modulated) output on pin 11 gives 2.5V most of time (in similar way to Pin 11 above) when joystick in neutral position. If z button is pressed, then joystick left/right will make it go down to 0V or up to 5V.
BUT: If both z and c buttons pressed (or just c button alone) then this Pin 11 output becomes controlled by Left/Right TILT of the nunchuck (via embedded accelerometer) and the L/R joystick component is disabled.
So: The output voltage (smoothed with an R/C filter) can be used as a steering input to some other device. If pressing z button, they you steer with joystick, if c button (or both) is being pressed, then you steer by tilting Nunchuck left or right.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top