Figure 1. Start with a loop.
(because of Eddie’s gear train) will make him move
• We looped the program, meaning it will repeat the
• We know that the light sensor outputs a value
between 0 and 100, with 0 being no light and 100
being very bright.
• Similarly, we understand that motor power is a
percentage (meaning it will be between 0 and
Go ahead and test your program in a decently-lit room.
If all goes well, Eddie should roll forward and slow down if
you cover his left light sensor. You’ll notice that there’s a
gradient of speed as you move your hand closer and closer.
This is because less and less light is getting to Eddie’s
sensor, meaning he’s supplying less and less power to the
What if we want to make Eddie move faster when it
Figure 3. Drag in a move block. Set the direction to backwards
(which will make Eddie move forward) and duration to
unlimited. Finally, click the tab indicated to expand the
“data hub” of the move action.
48 SERVO 12.2010
Figure 2. Add a light sensor check. Make sure you find this
under “Sensor” in the complete palette — DO NOT use the
“Wait” block. Also, be sure to uncheck “Generate Light” in the
bottom panel and select port 1.
gets dark, and slower when it’s light? Well, it’s actually
fairly simple, and only requires one more block.
We’ll need to take our input value (the light intensity)
and apply a simple formula to reverse the values. First, let’s
consider the numbers, and make an in/out table to help us
find the formula.
What we want here (see table
here) is an input intensity of 0 leading
to a motor power output of 100, and
Note that the IN + OUT values
always equal a total of 100 — never
more and never less. Knowing that,
let’s take a look at the first two rows
Figure 4. Here is the move action with the data hub expanded.
Hover your mouse over the icons to see what each one is. Each
of these are dynamic variables. They can be output (steering,
for instance, would return a value between -100 and 100
corresponding to the direction of the robot, which could be
used for other calculations) or they can be input, which we’re
about to do with motor power (we’ll tell the motors how much
power to use, based on another variable).