
142 Make: Robotic Arms
for (pos = 0; pos <= 90; pos++) {
servoTwo.write(135 - pos);
servoThree.write(45 + pos);
delay(50);
}
for (pos = 45; pos <= 135; pos++) {
servoFour.write(pos);
delay(50);
}
for (pos = 135; pos >= 45; pos--) {
servoFour.write(pos);
delay(50);
}
}
Here, all we have done is add in two more for loops to control motor 3. Just
as with our previous link, we’re going to start small and move from 45 to
135 degrees. Once you have compiled and uploaded your code, you should
see the base of the arm rotate, link 2 move from 45 to 135 degrees, and link
3 move from 45 to 135 degrees.
Now that we have tested all our main links, our ...