Now that we have written the class that controls the differential drive, it is time to test it. This is a good programming practice. You write your code in self-contained modules and then you test each module before you integrate it with the others to create a seamless whole. This allows you to catch bugs early and have confidence in the tested modules when your project inevitably fails early on.
We have already implemented a skeletal
LineFollower.java file (of the
Hello World variety), which we used to test the project setup. We will now modify it to test the differential drive.
I will present the
LineFollower.java file in its entirety first before explaining it in more detail:
import lejos.hardware.port.MotorPort; ...