Cricket Tutorial — Light Sensor and Waituntil Command

Just like touch sensors, the light sensor can be used with the waituntil command.

The difference is that you must compare the sensor value to a threshold to determine when the “waituntil” is complete.

                     Run Button ^

Click on the Click for Sensor A box, and select a Light Sensor.

Type the procedure on the right into the Procedure window and type test into the Run This line, or .

Then click Download and the Cricket's Run Button.

to test
send sensora
a, on
waituntil [sensora > 150]
a, off
send sensora
What happens? The procedure runs, sends the current value of the light sensor, and turns on the motor. If the light sensor value is less than 150 (check the Monitor Box), the Cricket gets trapped in the waituntil, with the motor spinning.

Now you can drag the slider on the light sensor, to simulate the sensor getting darker.

If you drag it up high enough, the sensor value will climb above 150. Then, the waituntil will exit, the motor will be turned off, and the new value of the light sensor will show up in the Monitor Box.

What happens when you run the procedure again (click on the Cricket’s Run Button) if you don’t adjust the light sensor after it finished the last time?

BACK: Light Sensor

UP to index

NEXT: Cereal Dispenser, Stage 3