O'Reilly logo

Lego Mindstorms EV3 Essentials by Abid H. Mujtaba

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing the differential drive

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.

Modified Line-follower code

I will present the LineFollower.java file in its entirety first before explaining it in more detail:

import lejos.hardware.port.MotorPort; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required