Programming instructions
light sensor kit • 2
Inventor’s Guide insert
accessories
sensor accessories
accessories
light sensor kit, continued
1 Technical overview
The light sensor uses a Cadmium Sulfoselenide photoconductive
photocell, or CdS cell for short. A CdS cell is a photoresistor, meaning
that its resistance value changes based on the amount of incident light.
This is an analog sensor, so its output covers a range of values
(in this case, from zero to five volts) rather than being only high (five
volts) or low (zero volts), as is the case for a digital sensor. This range of
outputs from zero to five volts is sent to the microcontroller, which reads
it as a range of integer values from 0 to 255. [For more detail, refer to
the Sensors chapter in your Vex Inventor’s Guide.]
For this particular sensor, a low value (around 0) corresponds to very
bright light, and a high value (around 255) corresponds to darkness.
We can then set a threshold value in our code to act as a trigger
for behaviors.
From this basic premise, we can build more complicated behaviors. For
example, if you have two light sensors on the front of your robot (one on
the left, and one on the right), then you can program your robot to follow
a bright light by telling it to steer toward bright light (in the direction
of the sensor that is receiving low values) and away from darkness
(away from the direction of the sensor that is receiving high values).
Maximum
Illumination
Minimum
Illumination
0V
5V
Analog Value =
0
255
Integer V
alue =
Go to Reference Links