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