the RedOrBlue program

In this section, you’ll build the RedOrBlue program, which uses the Light Sensor (or Color Sensor) to identify the blue and red balls that come with NXT (either the large ones that come with the original NXT retail kit and education set or the small ones that come with the NXT 2.0 retail kit). The Light Sensor measures the intensity of light; it does not measure the color directly. However, the amount of light an object reflects to the sensor depends on the color, and the difference between the Light Sensor readings for the blue and red balls is large enough for you to use it to distinguish between the two. When you run the program, the robot will say either “Red” or “Blue,” depending on which ball is placed in front of the ...

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.