Wiichuck Accelerometer Servo Control Issues

Hey Everyone,

I'm working on a ball labyrinth game controlled by two servos. I've been able to get the servos to respond to both the xy axis of the accelerometer of the Wiichuck but the servos are very shaky. The servos are hooked up directly to the digital inputs.

I've been reading about oversampling as a possible solution but I'm not too experienced with the arduino and coding in general any advice would be great. I've included a video as well: Servos connected to Labyrinth - YouTube

Thanks!

Code:

/*
 * WiiChuckDemo -- 
 *
 * 2008 Tod E. Kurt, http://thingm.com/
 *
 */

#include <Wire.h>
#include "nunchuck_funcs.h"
#include <Servo.h> 

Servo myservo;  // create servo object to control a servo 
Servo myservo2;

int val;    // variable to read the value from the analog pin 
int val2;
int loop_cnt=0;

byte accx,accy,zbut,cbut;
int ledPin = 13;


void setup()
{
    Serial.begin(19200);
    nunchuck_setpowerpins();
    nunchuck_init(); // send the initilization handshake
    
    Serial.print("WiiChuckDemo ready\n");
        myservo.attach(10);  // attaches the servo on pin 9 to the servo object 
        myservo2.attach(11);
}

void loop()
{

  
    if( loop_cnt > 1 ) { // every 100 msecs get new data
        loop_cnt = 0;

        nunchuck_get_data();

        accx  = nunchuck_accelx(); // ranges from approx 70 - 182
        accy  = nunchuck_accely(); // ranges from approx 65 - 173
        zbut = nunchuck_zbutton();
        cbut = nunchuck_cbutton(); 
            
        Serial.print("accx: "); Serial.print((byte)accx,DEC);
        Serial.print("\taccy: "); Serial.print((byte)accy,DEC);
        Serial.print("\tzbut: "); Serial.print((byte)zbut,DEC);
        Serial.print("\tcbut: "); Serial.println((byte)cbut,DEC);

  val = accx; 
  val = map(val, 70, 182, 0, 180 );     
  myservo.write(val);             
  delay(15);    

  val2 = accy;
  val2 = map(val2, 173, 65, 0, 180);  
  myservo2.write(val2);
  delay(15);
    }
    { 
     
    }
    loop_cnt++;
    delay(0);
}
Servo myservo;  // create servo object to control a servo 
Servo myservo2;

int val;    // variable to read the value from the analog pin 
int val2;

        accx  = nunchuck_accelx(); // ranges from approx 70 - 182
        accy  = nunchuck_accely(); // ranges from approx 65 - 173

I love consistency. Makes it so much easier to understand code.

  val = accx; 
  val = map(val, 70, 182, 0, 180 );

As opposed to

  val = map(accx, 70, 182, 0, 180 );

?

    delay(0);

Lovely.

The servos are hooked up directly to the digital inputs

I wire mine to outputs, but, whatever floats your boat.