Wii Nunchuck + 2 servos + JeonLab mini

One of my sons has complained one day that his Wii Nunchuck didn’t work and showed it to me. The joystick was loose but all the other function seemed to be fine. So he got a new Wii Nunchuck I got my own toy.  🙂

If you search the internet with key words, “wii nunchuck arduino,” you will find many blog posts, forum posts, and video clips.   I also found those interesting posts and videos some time ago and have once tried the Arduino Duemilanove and a Wii Nunchuck and a servo motor.   It just worked as it is supposed to do.   Of course I had to return the Wii Nunchuck to my son at that time, but now I have my own part.   Although the joystick was broken, the accelerometer and two switches, C and Z, were intact.   So I started removing the broken part and unnecessary part of the PCB and switches so that only the accelerometer was left.

Separated PCB
Treo_042011_003

PCB only
Wii Nunchuck PCB

The right part (joystick and button switch terminals) of the PCB has been cut.
Treo_041511_019

Treo_041511_021

Wii Nunchuck accelerometer and JeonLab mini v1.0  (wires: Blue-GND, Green-SDA(data), Yellow-SCK(clock), Orange-+3.3V; colors have no meaning here, I just used what I could find around)
chuck2servo_assemle 24

Since I’m going to supply +5V for servos, in order to provide +3.3V, I just simply attach a Zenner diode and a 100 ohm resister as shown below.
zenner diode for 3.3V

Before putting the JeonLab mini in a small blue box, an FTDI breakout board from Sparkfun was connected and my sketch (at the end of this post) was loaded.
chuck2servo_assemle 27

chuck2servo_assemle 29

chuck2servo_assemle 31

With a simple sketch below, it works fine to move two servos 0 to 180 degrees as responses of tilted angle of the Wii Nunchuck accelerometer PCB.

Some more pictures or video will be posted soon.

Sketch (JeonLab_Nunchuck.pde)

/*
 * Wiichuck_2servos
 * Apr 2011, Jinseok Jeon
 *
 * WiiChuck data read:
 *  thanks to WiiChuckDemo by Tod E. Kurt,
 *  http://todbot.com/blog/
 */

#include
#include
#include "nunchuck_funcs.h"

Servo servoX;
Servo servoY;
float tempx=0, tempy=0;

void setup()
{
  nunchuck_init();
  servoX.attach(10);
  servoY.attach(11);
}

void loop()
{
  for (int i = 1; i   {
    nunchuck_get_data();
    tempx += nunchuck_accelx();
    tempy += nunchuck_accely();
  }

  tempx = map(int(tempx/50.0), 74, 166, 0, 180);
  tempy = map(int(tempy/50.0), 73, 170, 0, 180);
  servoX.write(tempx);
  servoY.write(tempy);

  tempx = 0;
  tempy = 0;
}
Advertisements