Chapter 7: Drive and Turn – Moving Motors with Python
In this chapter, we will take the robot we started building in the last chapter, connect the motors to the Raspberry Pi, and build the Python code to make them move. We will cover programming techniques to create a layer between the physical robot and its behavior code, to reduce the impact of hardware changes. Our code and build will get the robot moving! We finish by programming the robot to drive a small set path. The robot code layer will serve as a foundation for all our robot behaviors, and the set path will demonstrate how to use it.
We cover the following topics in this chapter:
- Writing code to test your motors
- Steering a robot
- Making a
Robot
object—code for our experiments to talk to the robot - Writing a script to follow a predetermined path