Interfacing Arduino With Wii Nunchuck

I am quite new to arduino and am trying to interface the wii nunchuk with the arduino.
This is the library I am currently using as well as the code.

#include <Wire.h>
#include <ArduinoNunchuk.h>

#define BAUDRATE 19200

ArduinoNunchuk nunchuk = ArduinoNunchuk();

// SCL is connected to A5
// SDA is connected to A4
// +3.3V connected to +
// GND connected to -

void setup()

void loop()

  Serial.print("X: ");
  Serial.print(nunchuk.analogX, DEC);
  Serial.print(' ');
  Serial.print("Y: ");  
  Serial.print(nunchuk.analogY, DEC);
  Serial.print(' ');
  Serial.print("Acc X: ");
  Serial.print(nunchuk.accelX, DEC);
  Serial.print(' ');
  Serial.print("Acc Y: ");
  Serial.print(nunchuk.accelY, DEC);
  Serial.print(' ');
  Serial.print("Acc Z: ");
  Serial.print(nunchuk.accelZ, DEC);
  Serial.print(' ');
  Serial.print("Z btn: ");
  Serial.print(nunchuk.zButton, DEC);
  Serial.print(' ');
  Serial.print("C btn: ");
  Serial.println(nunchuk.cButton, DEC);

When I open the serial monitor, I cannot seem to get a change in the input when I move the analog stick or press the c or z button.
I cut the wii nunchuk wire which exposed 4 wires including yellow, red, white and green. I know from the tutorial online that

yellow = SCL = A5 pin
green = SDA = A4 pin
red = 3.3v = 3v3 pin
white = ground = ground pin

Voltage across each pin seems to a constant 3.3v
The only thing different from the tutorial that I did was instead of using an adapater like the man in the video I cut the wires and directly connected the to the arduino. I doubt this would make much of a difference.
Does any one have an idea how to solve this?

Tutorial used: Arduino Wii Nunchuck Tutorial - YouTube
Attached below is my really crappy solder job.
Thank You

ArduinoNunchuk nunchuk = ArduinoNunchuk();

should be

ArduinoNunchuk nunchuk;

Since you are attaching an I2C device, you should, before attempting to actually get anything from the device, run the I2C Scanner (you can google as well as I can) sketch to verify that the hardware is, at a minimum, connected correctly.

I am in the process of getting control of my Makeblock Ultimate 2.0 robot with a Wii nunchuck. I have gotten the wired chuck to work. Now I am moving on to a wireless connection with Nintendo hardware. I found the following 2011 code on the forum but the thread is closed to new posts. This thread will allow new posts. So, I am here. Functions is this old code have been deprecated, so I updated them. But I still get the error message

C:\Users\CL Plane Guy 3\Documents\Arduino\sketch_mar06b\sketch_mar06b.ino: In function ‘void setup()’:

sketch_mar06b:61:11: error: ‘CPU_FREQ’ was not declared in this scope



Since I did not write the code and do not understand it, I have no idea of the implied reason for the command or how it should be corrected.

Can anyone help?

* This file is an adaptation of the code by these authors:
* Tod E. Kurt,
* The Wii Nunchuck reading code is taken from Windmeadow Labs
* modified to include wireless nunchuck by Homer Manalo, October 2010
#include <Wire.h>
#include <math.h>
#include <utility/twi.h>

#define RADIUS 210  // probably pretty universal

#define numReadings 7

     byte cnt;
     uint8_t status[6];              // array to store wiichuck output
     byte averageCounter;
     //int accelArray[3][AVERAGE_N];  // X,Y,Z
     int i;
     int total;
     uint8_t zeroJoyX = 127;   // these are about where mine are
     uint8_t zeroJoyY = 134; // use calibrateJoy when the stick is at zero to correct
     int ZEROX = 510;
     int ZEROY = 460;
     int ZEROZ = 0;
     int lastJoyX;
     int lastJoyY;
     int angles[3];

     boolean lastZ, lastC;

     byte joyX;
     byte joyY;
     boolean buttonZ;
     boolean buttonC;
     const byte NunchuckID[6] = {0x00, 0x00, 0xA4, 0x20, 0x00, 0x00};
     byte getID[6] = {0};
     byte connection = 0;

byte C; //!< Stores press state of the C button
byte Z; //!< Stores press State of the Z button
int aveJX; //!< Stores the filtered joystick x-axis reading
int aveJY; //!< Stores the filtered joystick y-axis reading
int aveAX; //!< Stores the filtered accelerometer x-axis reading
int aveAY; //!< Stores the filtered accelerometer y-axis reading
//int last_reading[6]; //!< Stores last filtered reading from the joystick, accelerometer and buttons  
int readJX[numReadings]; //!< Stores readings from joystick x-axis in multiple successions
int readJY[numReadings]; //!< Stores readings from joystick y-axis in multiple successions
int readAX[numReadings]; //!< Stores readings from accelerometer x-axis in multiple successions
int readAY[numReadings]; //!< Stores readings from accelerometer y-axis in multiple successions

void setup() 

#define TWI_FREQ_NUNCHUCK 400000L
cnt = 0;
averageCounter = 0;

while(connection == 0)
Wire.beginTransmission (0x52);      // transmit to device 0x52
Wire.send (0xF0);           // sends memory address
Wire.send (0x55);           // sends data
if(Wire.endTransmission () == 0) 
 Serial.println("0x55 data send success");
 Wire.beginTransmission (0x52);      // transmit to device 0x52
 Wire.send (0xFB);           // sends memory address
 Wire.send (0x00);           // sends data
 if(Wire.endTransmission () == 0) Serial.println("0x00 data send success");
 else Serial.println("0x00 data send failed");
     Wire.beginTransmission (0x52);
     Wire.send (0xFA);
   while(Wire.endTransmission() != 0);

   Wire.requestFrom(0x52, 6);
   if(Wire.available() == 0) connection = 2;
     byte i=0;
       getID[i] = Wire.receive();
     for(byte j=0; j<6; j++)
       if(getID[j] == NunchuckID[j])
         if(j==0) connection = 1;
         else if(j>0 && connection == 1) connection = 1;
         else connection = 0;
       else connection = 0;
else Serial.println("0x55 data send failed");

if(connection == 1)
 ZEROX = 610; 
 ZEROY = 290;
 ZEROZ = 0;
 zeroJoyX =  128;
 zeroJoyY =  124;
 for(byte j=0;j<6;j++)
   Serial.print(getID[j], HEX);
   Serial.print(" ");
for (i = 0; i<3;i++) 
 angles[i] = 0;            
for(int j=0;j<=6;j++)
 readJX[j] = readJY[j] = readAX[j] = readAY[j] = 0;

     void calibrateJoy() {
         zeroJoyX = joyX;
         zeroJoyY = joyY;

sketch_mar06a:61:11: error: 'CPU_FREQ' was not declared in this scope



Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire 
exit status 1
'CPU_FREQ' was not declared in this scope