im trying to do a simple sketch using one of the example sketches to power a servo i have. just to mess around and get some experience with the duemilanove. this is my code. i know i missing something.
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = (0); // variable to store the servo position
void setup()
{
myservo.attach(0); // attaches the servo on pin 0 to the servo object
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
it also gives these error codes in the console.
avrdude: stk500_getsync(): not in sync: resp=0x30
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51
You are trying to attach pin 0 to the servo - pin 0 is used by the serial port. If you are using the arduino servo library that is distributed with the latest release, try attaching it to pin 9.
ok. when i try and modify the sweep value from 180 to say 90 or 45, it just keeps spinning. no stops. i changed both values for the 90-0 and the 0-90 but it doesnt change.
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = (0); // variable to store the servo position
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}