Using a wii nunchuck to control multiple servos

so, recently I have been looking in to a project about using a wii nunchuck as a controller by using the 3 axis accelerometer to control multiple servos in a robotic arm , however I still do not understand how to do this as the wii nunchuck adapter has 4 connected things, 1 for power( 3.3V I think) , the negative wire to ground, the one at goes in to the analog 4 and one that goes in analog 5. What do these two analogs signals do? I presume that they control the accelerometer and joystick, so how do you use the C and Z buttons, anyway when programming it at the start What you should it in the setup part, would you only use 1 variable for all axis of the accelerometer and then a similar thing for the joystick across x and y, also due to the c and z buttons not going directly into a Port e.g. Digital 9 how would you define them in the setup?

If you have any of the code for the setup and anything else I would be very great full!

Thanks.

They're not analogue signals, they're I2C

I'm pretty sure there's example code out in the wild.

What do these two analogs signals do?

They are the I2C buss which communicates with the electronics inside the nunchuck.

// Nunchuck test
// By Mike Cook
#include <I2C.h>
 
int outbuf[6]; // array to store results
void setup () {
  Serial.begin (19200);
  I2c.begin();
  I2c.pullup(0); // disable I2C pull ups
  I2c.timeOut(500); // half a second to prevent lock up
  Serial.print ("Finished setup\n");
  nunchuck_init (); // send the initialisation handshake
}

void nunchuck_init () {
 // I2c.write(address, registerAddress, data)  // set up start of read
  I2c.write(0x52, 0x40, 0x00);
}

void send_zero () { 
  I2c.write(0x52, 0x00);
}

void loop () {
 // I2c.read(address, numberBytes)
 Serial.println(" ");
 Serial.println("Raw data");
 I2c.read(0x52, 6);
 for(int j=0; j<6; j++){   // now get the bytes one at a time
      outbuf[j] =  I2c.receive();     // receive a byte
      if(outbuf[j] < 0x10) Serial.print("0"); // print leading zero if needed
      Serial.print(outbuf[j], HEX);          // print the byte
      Serial.print(" ");         
     }
     Serial.println(" ");  // new line
   printResults();  
  send_zero (); // send the request for next bytes
  delay (800);
}

// Print the input data we have received
// accel data is 10 bits long
// so we read 8 bits and the LS bits are in the last byte
void
printResults ()
{
  int z_button = 0;
  int c_button = 0;

 // byte outbuf[5] contains bits for z and c buttons
 // it also contains the least significant bits for the accelerometer data
 // so we have to check each bit of byte outbuf[5]
 z_button = outbuf[5] & 1;
 c_button = 1 ^ ((outbuf[5] >> 1) & 1) ^ (outbuf[5] & 1);
 
 outbuf[2] = (outbuf[2] << 2) | (outbuf[5] >> 2) & 0x3; // acc x
 outbuf[3] = (outbuf[3] << 2) | (outbuf[5] >> 4) & 0x3; // acc y
 outbuf[4] = (outbuf[4] << 2) | (outbuf[5] >> 6) & 0x3; // acc x
 for(int i=0; i<5; i++){
  Serial.print (outbuf[i], DEC);
  Serial.print ("\t");
 }
  Serial.print (z_button, DEC);
  Serial.print ("\t");

  Serial.print (c_button, DEC);
  Serial.print ("\t");

  Serial.println(" ");
}

You will also need the I2C master library not the normal wire one, find it at:-