How to do it...

The Pi-Bug robot uses three servos, one on either side and one in the middle. Mount each servo by drilling a hole on either side of the servo body, looping a wire or cable ties through it, and pulling to hold the servo tightly.

Bend the paper clip wire into a suitable shape to form the Pi-Bug robot's legs, and add a small kink that will allow you to wire the legs securely to the servo arms. It is recommended that you run the program first, with the Pi-Bug robot set to the home position h, before you screw the servo arms in place. This will ensure that the legs are located in the middle.

The following diagram shows the components on the Pi-Bug robot:

The layout of components on the Pi-Bug robot

Create the following servoAdafruit.py ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.