With the LeJOS project set up and tested, it is now time to implement the software that controls the differential drive. This is where the modular approach to programming comes in. From an implementation standpoint, the differential drive is simply one part of the robot, the part that controls its motion.
We already know that we require only four controls in our drive: forward, stop, rotate clockwise, and rotate counterclockwise. These four types of motion are achieved by controlling the two motors, left and right. With this in mind, we write a separate
DifferenentialDrive class (in a separate Java file
src/DifferentialDrive.java) that has four methods corresponding to the four types of motion. Each method when ...