
Page 49
Figure 3-5 shows a hypothetical graph of the light sensor value, along with the times when the dark and bright commands will be executed. Nothing happens until the sensor value enters either the
dark or bright value ranges.
Figure 3-5.
The sensor watcher
Remember that the RCX runs some tasks at the same time. If the dark commands and bright commands both take a while to execute, it's possible they may overlap. If the light sensor reading gets
into the bright range and abruptly drops back into the dark range, the dark commands will start running while the bright commands are still in progress. You should be aware of this possibility and
structure your code to deal with it. In Trusty's program, the dark and bright commands both execute quickly so they won't overlap.
Ambient Light
You have to be careful with the light sensor; its value depends on all the light it receives. This includes the reflected light from the red light that's part of the sensor as well as room light and
sunlight.
∗
In a line-following robot like Trusty, you really want to measure only the reflected light. In this case, it's in your interests to block out the room lighting, sunlight, light from your kid
brother's flashlight, and anything else distracting. The light level that's present in a certain place is called the
ambient
light. In a robot like Trusty, you might try surround the light sensor with dark
bricks to block out the ambient light. This can improve the accuracy of your sensor measurements. In this particular case, I didn't think it was necessary, but you might like to give it a whirl.
∗
The light sensor is even sensitive to the infrared light that is produced from the IR port.
Page 50
Where's That Red Light Coming From, Anyhow?
Isn't it odd that the light sensor, an input device, has a red light on it? How did that happen?
And how is that possible with only two wires connecting the sensor to the RCX?
The basic role of the RCX's inputs is to measure the value of the sensor. For certain types of
sensors, like the light sensor, the RCX also provides power to the sensor. It does this by
very quickly alternating between providing power and taking a measurement. The RCX
sends power to the light sensor for about 3 ms (thousandths of a second) and takes a
measurement for about .1 ms. It repeats this cycle over and over. (These timings only apply
to the standard firmware. In an alternate firmware such as legOS, the timings are entirely
different.) Inside the light sensor, an electronic circuit smooths out the pulses and provides
steady power to the red light.
Summary of Contents for MINDSTORMS Robots
Page 22: ...Page 18 The back tread wheels are anchored to the shafts with the 16t gears ...
Page 23: ...Page 19 Page 20 Next start building support for the drive motors ...
Page 26: ...Page 23 The touch sensors are attached only by the shaft that runs through them ...
Page 41: ...Page 41 ...
Page 43: ...Next build the support for the light sensor ...
Page 80: ...Page 85 Make sure the bump on the long pin is up against the 4u beam ...
Page 82: ......
Page 84: ...Page 89 ...
Page 85: ...Step 14 is similar to Step 11 take a deep breath and go slowly ...
Page 87: ...Page 91 ...
Page 88: ...Page 92 Make sure that the two sides are at the same angle They should mirror each other ...
Page 89: ...Page 93 Page 94 ...
Page 90: ...Structural Support Page 95 ...
Page 91: ...Idler Wheel Page 96 ...
Page 92: ...Page 97 Drive Motor ...
Page 93: ...While you re putting the motor in hold on to the worm gear so it doesn t slip off Page 98 ...
Page 94: ...Grabber Arm Motor ...
Page 95: ...Page 99 ...
Page 96: ...Page 100 RCX Attach the RCX on both sides as shown Page 101 ...
Page 158: ......
Page 159: ...Page 175 The 16t gears are nestled inside the tread wheels ...
Page 160: ...Page 176 ...
Page 161: ...Page 177 Attach the motors to output A and output C as shown Page 178 ...