Touch sensors produce a true or false reading, but light sensors produce a value that can vary between 0 and 255. To read the value from a light sensor, you use the sensora and sensorb commands.
|
Run Button ^ |
|
![]() |
You should see an image like this, as well as a slider that controls the light level. When you adjust the slider, it simulates the sensor receiving more or less light from the environment. When the sensors sun is bigger, its receiving more light; when its smaller, it is receiving less light. |
To find out the numerical value produced by the sensor, you can use the send command. This will cause the Cricket to transmit a value back to the computer. This value is displayed in the Monitor Box.
Try it right now. Type into the Command Center, send sensora and press Return. You should see a reading in the Monitor Box.
What value does the sensor return when it is seeing the maximum amount of light (when the sensors sun is the biggest)? What value does it produce in the dark?
When you are working with light sensors, its very important to get an idea of what kind of readings they are producing. When testing, you can download send sensora (or send sensorb) in the Run This line; then, each time you press the Crickets Run Button, it will transmit the current light sensor value back to your computer.