improving RedOrBlue
You can use the Range block to improve the RedOrBlue program from Chapter 5. The original program uses the Light Sensor or the Color Sensor in Light Sensor mode and assumes that all objects are either red or blue. In this section, you’ll change the program to eliminate this assumption, using the Range block to more accurately assign the color (red or blue) based on the Light Sensor reading.
The improvements made in this section can also be made to the RedOrBlueCount program. I’m using the simpler RedOrBlue program here to make it easier to concentrate on the use of the Range block. The original RedOrBlue program (shown in Figure 14-36) uses a Switch block to decide which color an object is based on the Light Sensor reading. ...
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