
Sensing
Forward Until Dark / Light • 2
©
Carnegie Mellon Robotics Academy / For use with LEGO
®
MINDSTORMS® Education NXT software and base set 9797
Forward until Dark Light Sensor (cont.)
Light Sensor
The Light Sensor (in the normal Active mode) shines a
light out in a cone in front of it, and measures how much
light comes back to it, from either reection or ambient
sources. See additional explanation below.
Detects:
Feedback:
Typical use:
Sample code:
Reected + Ambient light
Brightness (0-100)
Line detection
while (SensorValue(lightSensor) > 40)
will run the while() loop as long as the
light sensor value remains brighter
than 40.
And now, let’s look at a new sensor.
This is the Light Sensor. When turned on, it shines a cone of red light out from the red LED, and
measures how much of it comes back into the light detector through the clear lens.
Clear lens
A light detector measures
how much light comes back.
Red lens
A cone of red light shines out
from the red LED.
Comentários a estes Manuais