Writing the control software
The Arduino program for this robot is more extensive (in terms of lines of code) than all the other ones we developed so far. We will not print the entire code here, but only sections of it that will help you understand the key concepts. You can always refer to the full code in the GitHub repository that accompanies this book.
Driving the motors
We are using the same motor driver board that we used in the previous chapter, so we could just reuse the motor driver code without changes. However, simply copying code from one project to another is not the best way to do this, since older projects will not be able to benefit from improvements you make in newer projects. The solution to this problem, you guessed it, is to package the motor driver code as a library!
Motor driver library
We already learned how to turn object-oriented code that you want to reuse into a library. Our motor driver library consists of a MotorDriver
class that exposes an interface...