improving RedOrBlueColorMode
The RedOrBlueColorMode program from Chapter 5 (shown in Figure 14-38) is similar to the RedOrBlue program, except that it uses the Color Sensor to determine the color directly. The program does a good job of identifying red objects, but it calls all other objects blue. You could fix this problem using nested Switch blocks like you did for the RedOrBlue program, but there is an easier way.
Figure 14-38. The RedOrBlueColorMode program
The Color Sensor block can determine the color of an object and generate an output value using the values in Table 14-6. In the previous section, the Switch blocks made decisions based on a ...
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.