Hi, my name is Guzz and i'm new on the arduino world. I'm having some trouble to write a code to control 4 servos with a arduino, and i dont know what can be wrong with my code, i'm not a programmer (yet). I wrote this code based on de sweep code from the arduino examples. ''The code compiles fine, but when i try to upload to the board it crashes. Im using the arduino duemilanove with atmega 328." - solved - The code is like this...

Servo myservo0; // create servo object to control a servo // a maximum of eight servo objects can be created

int pos0 = 0; // variable to store the servo position

Servo myservo1; // create servo object to control a servo // a maximum of eight servo objects can be created

int pos1 = 0; // variable to store the servo position

Servo myservo2; // create servo object to control a servo // a maximum of eight servo objects can be created

int pos2 = 0; // variable to store the servo position

Servo myservo3; // create servo object to control a servo // a maximum of eight servo objects can be created

int pos3 = 0; // variable to store the servo position

void setup(){ myservo0.attach(9); // attaches the servo on pin 9 to the servo object myservo1.attach(8); // attaches the servo on pin 8 to the servo object myservo2.attach(7); // attaches the servo on pin 7 to the servo object myservo3.attach(5); // attaches the servo on pin 5 to the servo object}

void setup(){ myservo[0].attach(9); // attaches the servo on pin 9 to a servo object myservo[1].attach(8); // attaches the servo on pin 8 to a servo object myservo[2].attach(7); // attaches the servo on pin 7 to a servo object myservo[3].attach(5); // attaches the servo on pin 5 to a servo object}

Two things here:The initialisation isn't necessary because:a) it's done at the start of the for loops anyway.b) the values are reset to zero when the program is started, but only because of their global scope.