
82 Make: Robotic Arms
#include <Servo.h>
Servo servo1;
Servo servo2;
void setup() {
servo1.attach(3);
servo2.attach(5);
}
void loop() {
servo1.write(90);
servo2.write(90);
delay(1000);
for (int pos = 0; pos <= 30; pos++) {
servo1.write(90 + pos);
servo2.write(90 + pos);
delay(100);
}
for (int pos = 30; pos >= 0; pos--) {
servo1.write(90 + pos);
servo2.write(90 + pos);
delay(100);
}
delay(1000);
}
Once this updated code is compiled and uploaded,
you should see a movement very similar to what
you saw before, but this time, the two mirrored links
of our system are following one another, rather
than moving closer and farther from each other.
This ...