Having an issue that involves controlling 4 servos with the Wii Nunchuck

Unfortunately I am a “noob” and I have tried my best to solve issues through research and trial and error but I seem to have hit a wall. I have a project that I am working on that includes using the Wii Nunchuck attached to an Arduino Uno. I am only concerned with using the Nunchuck’s Joystick (plus c & z buttons) and not the accelerometer. I am using the library from:


I also used the code from http://forum.arduino.cc/index.php?topic=84267.0 as a starting point.

I have tried to modify the code and strip it down to only include the joystick information. I have 2 sets of servos and I want to control each set simultaneously.

Holding down the C button and moving the X-axis will move servo 1 and servo 2 90deg. CW and CCW
Holding down the Z button and moving the Y-axis will move servo 3 and servo 4 CW and CCW continuously until released (Continuous rotation servos)

Everything seems to work fine; the C button with the X-axis works as I want it to. However the Z button and the Y-axis does not. I can hold down Z and move the joystick down and they will both move CW. When I move the joystick up, servo 3 just barely moves CCW and servo 4 doesn’t seem to do anything.

My Code is:

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

ArduinoNunchuk nunchuk = ArduinoNunchuk();

int xjoystick;
int yjoystick;

void setup() {
  pinMode(10, OUTPUT); //servo 1 used with C button
  pinMode(11, OUTPUT); //servo 2 used with C button
  pinMode(5, OUTPUT); //servo 3 used with Z button
  pinMode(6, OUTPUT); //servo 4 used with Z button


void loop(){  
  if(nunchuk.cButton == 1 && nunchuk.zButton != 1){
    digitalWrite(10, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    xjoystick = nunchuk.analogX;

    analogWrite(10, xjoystick);
    analogWrite(11, xjoystick);

  if(nunchuk.zButton == 1 && nunchuk.cButton != 1){
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    yjoystick = nunchuk.analogY;

    analogWrite(5, yjoystick);
    analogWrite(6, yjoystick);
  if(nunchuk.cButton == 1 && nunchuk.zButton == 1){
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);

I am sure there might be issues with my code or areas that I don’t need. Feel free to let me know what I can change.
If you have any information or can point me in the right direction I will greatly appreciate it.

Thank You

Feel free to let me know what I can change.

Change your code to use the Servo library, as a start.

Serial.print()s are essential for debugging, but completely missing from your code.