Figure 9. Connect the light sensor intensity data port to the
“B” port on the math block.
Download your program to Eddie, and you’re ready to
Making Eddie Follow Light
Now that we understand how dynamic variables work,
it’s time to get on to the main challenge for this
installment: Make Eddie follow a light!
First, we need to learn about steering. The steering
data port on the move block accepts any numeric value
between -100 and 100. An input of -100 will make Eddie
turn left at full speed, while an input of 100 will
make Eddie turn hard right. We’ll need to do some
math to find our formula to turn towards and
We have two light sensors, each of which can
detect light intensity values between 0 and 100. If
the light sensor on the left sees light (a higher
intensity value), we want Eddie to turn left. Similarly,
if the light sensor on the right sees light, we want
Eddie to turn right. Take a look at the table here.
Figure 11. Finally, attach a data wire from the “#” output port on
the math block to the power level input port on the motor block.
50 SERVO 12.2010
Figure 10. Select the math block, change the operation to
“Subtraction,” and type in “100” for “A.”
This formula might seem more obvious than the
last one, but in case it doesn’t, let’s consider the
• When no light is seen (both inputs are 0), the output
is also 0. This suggests that there are no terms in the
formula aside from the variables.
RIGHT - LEFT = STEER
Unfortunately, we’ve forgotten that
Eddie’s gear train reverses the direction of
his turns! Therefore, the real formula
Figure 12. Start with a new program and add a loop.