Figure 13. Drag in two light sensor blocks and select ports 1
and 2, respectively. Be sure to uncheck “Generate Light.”
we’re looking for is:
LEFT - RIGHT = STEER
Close enough, right?
With that in mind, let’s write the program.
Test the Program
Eddie should turn away from your hand if you cover
one of his light sensors, or turn towards a flashlight if you
shine it at him.
Now that we’ve gotten Eddie approaching the light,
here are some fun experiments to try:
• Try different power levels to adjust Eddie’s speed.
Figure 15. Wire the sensors to the subtraction block as
indicated. Note: Light sensor 2 should connect to port 1 on
the subtraction block; light sensor 1 should connect to port 2.
Figure 14. Find the math block and select “Subtraction.”
Find your favorite!
• Change Eddie’s gear train to further control his
• Try programming Eddie to respond more extremely to
smaller changes in light (hint: multiplication).
• Try writing a similar program that uses the light
sensors to control the motors independently. In other
words, light sensor 1 controls the left motor (B) and
light sensor 2 controls the right motor (C).
In this edition, we dove into dynamic variables and data
wires. We programmed Eddie to react to light, then to
follow it. Along the way, we learned about determining
formulas based on input/output values.
In the January edition, we’ll be making Eddie
even cooler in an article you don’t want to miss! Stay
Figure 16. Finally, add a motor block. Set the direction to
backwards, power to 100%, and duration to unlimited. Then,
SERVO 12.2010 51