Wiring
Each servo has three wires. Connect every brown (or black) wire to the ground rail of the breadboard and every red wire to the 5 V rail. The remaining signal wires go to PWM pins on the HERO board (the pins marked with a ~ squiggle), because a servo is driven with an analog-style pulse:
| Servo | Signal pin |
|---|---|
| Base (rotation) | 3 |
| Horizontal (reach) | 5 |
| Vertical (lift) | 6 |
| Claw | 9 |
The narrator swaps the words "horizontal" and "vertical" once in the video. Follow the sketch below; if your arm lifts when you expected it to reach, swap the two pins in the attach() lines.
Test one servo at a time
Before running the full sketch, write a single value to one servo in setup(), e.g. base.write(90); (90 degrees is the middle of a 180-degree servo), upload, and confirm that joint moves. Do the base, horizontal and vertical servos this way.
Calibrate the claw before you drive it
The claw only uses a small part of the servo's range. Remove the two screws holding the claw's servo horn (watch for the spacer that falls out), upload claw.write(0);, then reattach the horn so the jaws are fully open at 0 degrees. About 30 degrees closes them. Never command the claw past the point where the jaws touch, or the servo will strain against itself.
The sweep sketch
The complete code below sweeps the base, horizontal and vertical servos from 0 to 180 degrees and back with a 50 ms step, and opens and closes the claw only while the counter is below 30. Do not forget the semicolons and the delay; without the delay the arm thrashes.