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 5. Click the “Intensity” port on the light sensor block,<br />
then the “Power” port on the motor block to connect the<br />
two with a “data wire.”<br />
of values, <strong>and</strong> try to find the formula we’d need to make<br />
them a reality.<br />
Start by considering the first row of values <strong>and</strong> asking<br />
yourself “What would I need to do to the number 0 to<br />
change it to the number 100?” The first possibility is<br />
obvious: You could add 100 to 0 to make it equal 100.<br />
(0) + 100 = 100<br />
or<br />
(IN) + 100 = OUT<br />
Let’s try that with the second set of values:<br />
100 + 100 =/= 0<br />
So, that formula is a no-go. We could also try the<br />
opposite operation: subtraction. How could we use the<br />
number 0 in a subtraction operation to equal the number<br />
100? We can’t subtract a positive number from 0 because<br />
that would only make a negative output. We could,<br />
Figure 7. Start by clicking the data wire to select it, then<br />
pressing delete to delete it.<br />
Figure 6. Click the tab under the move action again to collapse<br />
the unused data ports.<br />
however, subtract 0 from the number 100 to equal 100.<br />
100 - (0) = 100<br />
or<br />
100 - (IN) = OUT<br />
Let’s try that with the second row of values:<br />
100 - (100) = 0<br />
Looks good so far! Let’s just try it with the other three<br />
rows:<br />
100 - (50) = 50<br />
100 - (25) = 75<br />
100 - (75) = 25<br />
Success! Our formula works! Now we just need to<br />
implement it in the program. We do this by using the<br />
“Math” block.<br />
Figure 8. Find the “Math” block in the “Data” menu on the right<br />
<strong>and</strong> drag it between the light sensor <strong>and</strong> motor blocks.<br />
SERVO 12.2010 49<br />
worldmags