This guide will teach you how to connect the Wii Nunchuk Controller to your Geekduino or Arduino using the Wii Adaptor Board.
The Wii Nunchuk Controller uses the I2C protocol to communicate. The controller runs on 3.3v, so we've designed the Wii Adaptor Board to handle the logic level conversion to 5v for your Geekduino/Arduino.
We've tested the Wii Adaptor board with our Wii Nunchuk Controllers and Wii Nunchuks. The board should work with standard nunhucks/classic controllers, though we cannot guarantee compatibility. If your board is not compatible with your controller, you can return it for a refund.
Setting up the Arduino Software
If you have not already set up your Geekduino/ Arduino compatible board, please see the Geekduino Getting Started Guide. This guide will assist you in getting set up with the Arduino software as well as install libraries and test sketches for RobotGeek Robots and this controller.
ArduinoNunchuk Library for the controller is included in the RobotGeek Libraries and Tools Download that you setup in the Geekduinio Getting Started Guide.
Wiring the Controller
The Wii Adaptor Board is electronically compatible with any microcontroller with a 5v I2C connection. Here are several examples of wiring the Wii Adapter Board.
Make sure the orientation of your Nunchuk Controller connector is correct when connecting to the adaptor. Plugging the unit in the wrong way will cause it to malfunction. The flat black plastic should point upwards and the clear plastic piece should face downwards.
The Wii Adaptor board is designed to mount on the edge of your workbench or project. However, you can remove the clear plastic piece on the bottom of the nunchuk connector by removing the two phillips screws, allowing you to mount the part anywhere on your board..
|Sensor Shield Pin||Wii Adapter Pin|
The Wii Adapter can be connected directly to a Geekduino / Arduino using a combination of 4-pin Squid Cables and 2-pin Couplers . Put the couplers into the female sockets on the Geekduino/Arduino, and connect the 4 single ends into the correct pins on the Geekduino/Arduino. The single 4-pin end of the cable plugs right into the Adapter Board
|Geekduino Pin||Wii Adapter Pin|
|ArbotiX-M Robocontroller||Wii Adapter Pin|
|D17 Signal Pin||SDA|
|D16 Signal Pin||SCL|
|D17 5V Pin (or any 5V pin)||VCC|
|D17 Ground Pin (or any GND pin)||G|
When you installed the RobotGeek Tools and Libraries, you installed the library and examples for the Nunchuk. You can find the
ArduinoNunchukDemo sketch in the 'Examples' menu.
File -> Examples -> ArduinoNunchuk -> ArduinoNunchukDemo
Now load the sketch onto your Geekduino. Once the sketch has uploaded, open your Serial Monitor
Tools -> Serial Monitor
Make sure the monitor is set to '9600' from the drop-down menu. You should start to see data coming in from the Serial monitor that corresponds to your controller. As you press buttons and move joysticks you should see data changing on the screen.
nunchuk.init(); - the init function must be called once in
setup() to initialize the Nunchuk Controller. In order to not overload the Nunchuk, the ArduinoNunchuk Library will limit the update rate of the controller to 30Hz (once every 33ms). See the Advanced Section for more information.
nunchuk.update(); - the update function must be called before reading the
nunchuk variables to make sure you have the latest values.
In order to limit the processing time spent on updating the controller, the variables in the
nunchuk class will only be updated if a minimum amount of time has passed since the last data read (33ms be default) If this function is called faster than the update rate then the data will not be updated. For most applications, you can call
nunchuk.update(); as often as you'd like and let the library take care of the rest. See the Advanced Section for more information.
The Wii Nunchuk Controller has 2 analog inputs you can access through the
|Input||Variable||Left/Down Value||Centered Value*||Right/Up Value|
|Left Joystick X / Horizontal||
|Left Joystick Y / Vertical||
*Keep in mind that each nunchuk is a little different, so while the outer limits (0-255) will stay the same, the centered position may vary. We recommend a deadband of at least 20 (see demo code)
The Wii Nunchuk Controller has 2 different digital inputs you can access through the
|Input||Variable||Unpressed Value||Pressed Value|
The Wii Nunchuk Controller has a built in 3-axis accelerometer you can access through the
|Input||Variable||Minimum Value||Maximum Value|
From the accelerometer the Library can also derive pitch and roll. Please note that it is not possible to derive Yaw from a 3-axis accelerometer. Also note that Pitch is only available in one hemisphere (180 degrees).
|Input||Variable||Minimum Value||Centered Value*||Maximum Value|
Library Documentation and Other Examples
File -> Examples -> ArduinoNunchuk -> nunchukLEDControl
This examples will turn an LED on pin 13 on when you press z and off when you press c. An LED on pin 3 will change intensity via PWM when you move the joystick up/down.
File -> Examples -> ArduinoNunchuk -> nunchukJoystickServoDegrees
This Sketch will show you how to control 1 servo from a single joystick. Plug your servo into digital port 3, move the joystick up/down to adjust the servo position. Uses
servo.write to send degrees to the servo.
File -> Examples -> ArduinoNunchuk -> nunchukJoystickServoMicroseconds
This Sketch will show you how to control 1 servo from a single joystick. Plug your servo into digital port 3, move the joystick up/down to adjust the servo position.Uses
servo.writeMicroseconds to send microsecond pulses to the servo.
File -> Examples -> ArduinoNunchuk -> nunchukAccelServo
Very basic control using the accelerometer to control servos. This is unfiltered and will be erratic. See this project for information on smoothing / averaging.
File -> Examples -> ArduinoNunchuk -> nunchukBuzzerControl
This Sketch will control the frequency of a buzzer or speaker attached to pin 3. Push the buttons to set specific frequencies or move the joystick to manually adjust the frequency.
Changing the Update Rate
nunchuk.init(int updateRate); - It is also possible to manually set the update rate by passing an integer to the
init() function with the minimum time between reads. For example
would limit the controller to updating one per second.
would have the controller to update as fast as possible
If you're using a 3.3v system, you can solder a 4-pin male header onto the open solder points on the board - this will allow you to connect directly to the controller's pins, without the logic level conversion.
Logic Level Shifter
In a pinch, the Wii Adaptor board can be used as a general purpose 5v-3.3v logic level converter. You can solder a 4-pin male header onto the open solder points on the board for the 3.3v side logic and connect to the standard pins for the 5v logic.
Are you ready to dive even deeper into the world of Arduino? Then take a look at Robotgeek 101! RobotGeek 101 is a step by step guide that will teach you how to build, wire, and program your Geekduino/Arduino. Through RobotGeek 101 you will learn the basics of Arduino like digital input and output, and move on to more advanced topics like PWM and servo control. By the end of RobotGeek 101 you'll be well equipped to start modifying our demo code and creating your own custom applications.