#include <Servo.h>
Servo Base; // create servo object to control a servo
Servo servoLeft;
Servo servoRight;
Servo Claw;
// twelve servo objects can be created on most boards
int pos; // variable to store the servo position
void setup() {
Base.attach(9); // attaches the servo on pin 9 to the servo object
servoLeft.attach(10);
servoRight.attach(11);
Claw.attach(12);
}
void loop() {
Base.write(0);
servoLeft.write(0);
servoRight.write(0);
Claw.write(0);
delay(3000);
for (pos = 10; pos <= 160; pos += 1) { // goes from 10 degrees to 160 degrees
// in steps of 1 degree
Base.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 140 ms for the servo to reach the position
}
for (pos = 50 ; pos <= 160; pos += 1) { // goes from 50 degrees to 160 degrees
servoLeft.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 40 ms for the servo to reach the position
}
for (pos = 80; pos <= 140; pos += 1) { // goes from 80 degrees to 140 degrees
// in steps of 1 degree
Claw.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 40 ms for the servo to reach the position
}
for (pos = 40; pos <= 140; pos += 1) { // goes from 40 degrees to 140 degrees
servoRight.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 40 ms for the servo to reach the positionM
}
for (pos = 140; pos >= 60; pos -= 1) { // goes from 140 degrees to 60 degrees
// in steps of 1 degree
Claw.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 40 ms for the servo to reach the position
}
for (pos = 140; pos >= 40; pos -= 1) { // goes from 140 degrees to 40 degrees
servoRight.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 40 ms for the servo to reach the positionM
}
for (pos = 160 ; pos >= 50; pos -= 1) { // goes from 160 degrees to 50 degrees
servoLeft.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 40 ms for the servo to reach the position
}
for (pos = 160; pos >= 10; pos -= 1) { // goes from 1600 degrees to 10 degrees
// in steps of 1 degree
Base.write(pos); // tell servo to go to position in variable 'pos'
delay(40);
}
for (pos = 50 ; pos <= 160; pos += 1) { // goes from 50 degrees to 160 degrees
servoLeft.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 40 ms for the servo to reach the position
}
for (pos = 40; pos <= 140; pos += 1) { // goes from 40 degrees to 140 degrees
servoRight.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 40 ms for the servo to reach the positionM
}
for (pos = 80; pos <= 140; pos += 1) { // goes from 80 degrees to 140 degrees
// in steps of 1 degree
Claw.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 40 ms for the servo to reach the position
}
for (pos = 140; pos >= 60; pos -= 1) { // goes from 140 degrees to 60 degrees
// in steps of 1 degree
Claw.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 40 ms for the servo to reach the position
}
for (pos = 140; pos >= 40; pos -= 1) { // goes from 140 degrees to 40 degrees
servoRight.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 40 ms for the servo to reach the positionM
}
for (pos = 160 ; pos >= 50; pos -= 1) { // goes from 160 degrees to 50 degrees
servoLeft.write(pos); // tell servo to go to position in variable 'pos'
delay(40); // waits 40 ms for the servo to reach the position
}
}