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. The code is like this...
#include <Servo.h>
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(

; // 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 loop()
{
for(pos0 = 0; pos0 < 180; pos0 += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo0.write(pos0); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
for(pos0 = 180; pos0>=1; pos0-=1) // goes from 180 degrees to 0 degrees
{
myservo0.write(pos0); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
for(pos1 = 0; pos1 < 180; pos1 += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo1.write(pos1); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
for(pos1 = 180; pos1>=1; pos1-=1) // goes from 180 degrees to 0 degrees
{
myservo1.write(pos1); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
for(pos2 = 0; pos2 < 180; pos2 += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo2.write(pos2); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
for(pos2 = 180; pos2>=1; pos2-=1) // goes from 180 degrees to 0 degrees
{
myservo2.write(pos0); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
for(pos3 = 0; pos3 < 180; pos3 += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo3.write(pos3); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
for(pos3 = 180; pos3>=1; pos3-=1) // goes from 180 degrees to 0 degrees
{
myservo3.write(pos3); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
}
If someone could please take a look and tell me what could be wrong i'd be most greatfull.
PS: I wasnt sure if i should create a new post, but since we are discussing servos and arduino here i was hoping no one would mind.
Thanks everybody