NXT Programming


Lesson 4

In this lesson we will make the LEGO 9797 car follow a black line and stop at the end of the line when the car drives into a goal zone - a green rectangular piece of paper at the end of the black line. The idea is that we will try to use the light sensor to detect three different colors.

Figure 1 The NXT light sensor.

Black White Detection

First, you should mount the sensor on the LEGO 9797 car as described in LEGO Mindstorms Education NXT Base Set 9797 building instruction page 32 to page 34. Second, make a program that use and test the class BlackWhiteSensor.java. After calibration, place the car with the light sensor over different dark and bright areas and investigate how well the BlackWhiteSensor works.

Line Follower with Calibration

As an application of the BlackWhiteSensor try the program LineFollowerCal.java. The program uses the simple class Car.java to move the car.

ThreeColorSensor with Calibration

Use the idea and structure of the BlackWhiteSensor to program a class ThreeColorSensor that can detect three colors: black, green and white. Make a test program that investigate the usefulness of the class.

Line Follower that stops in a Goal Zone

Use the ThreeColorSensor to make a line follower that stops in a green goal zone.

PID Line Follower

It is possible to make a line follower with just one light sensor that follows the line more smoothly and drive faster if a PID regulator is used, [2]. Try this.

Color Sensor

In the LEGO Mindstorms series there is also a color sensor. Use the test program ColorSensorSensor.java to investigate the information that the class ColorSensor provide in Full mode. Place the color sensor over black, white and green to figure out if the information provided can be used to distinguish the three colors.

Figure 2 The NXT color sensor.

Is it possible to use the color sensor for both following the black line and stop in the goal zone?



Last update: 21-02-15