Nunchuk Controller Kit Getting Started Guide

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.

Contents:

  1. Arduino Setup
  2. Wiring
  3. Testing
  4. Library and Examples
  5. Advanced Use
  6. RobotGeek 101

Setting up the Arduino Software

Geekduino Getting Started Guide

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.

The ArduinoNunchuk Library for the controller is included in the RobotGeek Libraries and Tools Download that you setup in the Geekduinio Getting Started Guide.

Back to Contents

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.

b_500_500_16777215_00__images_tutorials_wii_wii-adapt-instruction-1.jpg b_500_500_16777215_00__images_tutorials_wii_wii-adapt-instruction-2.jpg

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

This Wii Adaptor Board was designed for use with the RobotGeek Sensor Shield. The board will connect directly to the Sensor Shield's I2C port using a 4 Pin Sensor Cable.

Sensor Shield Pin Wii Adapter Pin
SCL SCL
SDA SDA
5V VCC
G GND
b_500_500_16777215_00__images_tutorials_wii_sensorShieldAdapator_bb.png
Direct Geekduino /Arduino Connection

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
5 SCL
4 SDA
5V VCC
Gnd GND
b_500_500_16777215_00__images_tutorials_wii_unoAdaptor_bb.png
ArbotiX-M Robocontroller

The Wii Adapter Board can be connected to the ArbotiX-M Robocontroller using a 4-pin Squid Cable.

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
b_500_500_16777215_00__images_tutorials_wii_arbotixAdaptor_bb.png

Back to Contents

Testing the Controller

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.

Back to Contents

Library Documentation

Setup Functions

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.

Accessing Data

The Wii Nunchuk Controller has 2 analog inputs you can access through the nunchuk class.

Input Variable Left/Down Value Centered Value* Right/Up Value
Left Joystick X / Horizontal nunchuk.analogX 0 128 255
Left Joystick Y / Vertical nunchuk.analogY 0 128 255

*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 nunchuk class.

Input Variable Unpressed Value Pressed Value
Z Button nunchuk.zButton 0 1
C Button nunchuk.cButton 0 1

The Wii Nunchuk Controller has a built in 3-axis accelerometer you can access through the nunchuk class.

Input Variable Minimum Value Maximum Value
Accelerometer X nunchuk.accelX 0 1023
Accelerometer Y nunchuk.accelY 0 1023
Accelerometer Z nunchuk.accelZ 0 1023

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
Pitch nunchuk.pitch 0 90 180
Roll nunchuk.roll -179 0 179

Back to Contents

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.

Back to Contents

Advanced Use

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

nunchuk.init(1000);

would limit the controller to updating one per second.

nunchuk.init(0);

would have the controller to update as fast as possible

3.3v Systems

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.

Back to Contents

RobotGeek 101

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.

RobotGeek 101

Feedback Form


Search