Here is the code:
#include <Servo.h>
Servo myservo1;
Servo myservo2;
int pos = 0;
void setup()
{
myservo1.attach(9);
myservo2.attach(7);
}
void loop()
{
for(pos = 0; pos < 180; pos += 1)
{
myservo1.write(pos);
delay(15);
myservo2.write(pos);
delay(15);
// waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1)
{
myservo1.write(pos);
delay(15);
myservo2.write(pos);
delay(15);
}
}
No comments:
Post a Comment