Creating a program to control your biped

Now you know that you can talk to your servo motor controller and move your servos. In this section, you'll create a Python program that will let you talk to your servos to move them at specific angles. You can use Python as it is very simple and easy to run.

Let's start with a simple program that will make your legged mobile robot's servos go to 90 degrees (which should be somewhere close to the middle between the 0 to 180 degrees you can set). Here is the code:

Creating a program to control your biped

Here is an explanation of the code:

  • #!/usr/bin/python: This first line allows you to make this Python file execute from the command line.
  • import serial ...

Get Raspberry Pi: Amazing Projects from Scratch 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.