Programming Highlights

 

 

 

Setting a light sensor condition for a Sensor Watcher or a Stack Decision Maker Testing for a light condition can be set automatically by the program or manually by the user.

 

 

Autoset: Three conditions can be set automatically —Bright, Dark, and Blink. For the Bright or Dark conditions the program registers the first incoming reading from the light sensor as “neutral.” Any subsequent light reading is then compared to the neutral value. It is considered Bright when it’s higher than neutral and Dark when lower. It might be helpful to think of these conditions as relative to a neutral, either brighter or darker than that first reading. The range designated to Dark is always lower than neutral, and the range designated to bright is always higher than neutral.

The Blink condition is always a quick change between bright and dark, analogous to the touch sensor’s click event.

Here is an example of a program that sets the light sensor conditions automatically.

 

Return to Top

 

 

Tech Guide

 

 

Manual Set: Bright, Dark and Range can be set manually by the programmer.

 

 

 

© The LEGO Group

 

When the condition If Bright is set manually, you decide on the lower limit of the condition, say 75. Bright is then considered as a light reading greater than 75. Note that the block changed from reading “If bright” to “If light.”

 

 

© The LEGO Group

 

When the condition If Dark is set manually, you decide on the upper limit of the condition, say 45. Dark is then considered as a light reading less than 45. Note that the block changed from reading “If dark” to “If light.”
 

 

© The LEGO Group

 

 A range is always set manually. When setting the range you define both the lower and upper limits of the light range.

 

Return to Top

 

 

Tech Guide

 

Different programs, similar output: We use the ZZforever and the Follower programs in the “Thinking about It” section of the student activity to help students understand the difference between a program that uses input and a program that does not use input.

 

In a program that does not use input to control its flow, the behavior is predictable. In other words, for a given robot, looking at the program one can describe the path the robot will follow under any conditions.

 

 

 

Beyond the Basics

 

Return to Top