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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access