selecting the sensor trigger values

The first enhancement will address the flexibility requirement. The LineFollower program shown in Figure 18-1 uses hard-coded values, meaning the trigger values for the Light Sensor are set in the program and can’t easily be changed. The settings work fine with my NXT using the LEGO test pad, with the lighting in my office, but they may not work as well with a different Light Sensor, line, or different lighting. To avoid hard-coding the trigger values, you can write a program that collects the information needed to determine the trigger values. This makes the line-following program more flexible because it can adapt to different sensors, lines, and lighting conditions.

Since you’re using a dark line on a light ...

Get The Art of LEGO MINDSTORMS NXT-G Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.