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

Controller

The Controller class is the brain of the Line-follower robot. It integrates color sensor and differential drive, and it makes the decisions that allow the robot to follow a line/path. We will rewrite the main LineFollower class (inside LineFollower.java) to simply create a Controller object and hand over control to it.

Let's look at a basic (initial) implementation of Controller to get an idea of what we are talking about.

The LineFollower.java file

We start with the modified LineFollower class that simply hands control over to Controller:

import lejos.hardware.port.MotorPort; import lejos.hardware.port.SensorPort; public class LineFollower { public static void main(String[] args) { Controller controller = new Controller(SensorPort.S1, ...

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