reverse and turn. You’ll notice that as he reverses and turns, he’ll move in chunks. After each of these short movements,
he’s checking his ultrasonic sensor to see if his opponent is in front of him. If all goes well, he should immediately charge
another robot, your hand, or even a cat that walks in front of the ultrasonic sensor.
Figure 7. Add a math block from the data palette and run a
data wire from Value on LoopCount to A on the math block.
Select the math block. For Operation select Addition,
and for B, type in 1.
Figure 10. For the < eight inches side of the switch, add a
motor block that will go forward at full power for an unlimited
duration. This is what we want Eddie to do when he sees
a nearby robot.
Figure 8. Add a variable block and select LoopCount again.
Choose Write, and run a data wire from the result of the math
block to the value of the variable block. This will add 1 to our
LoopCount variable each time our loop runs, giving us a way
to track it.
Figure 11. On the > eight inches side of the switch, add a
Figure 9. Add a switch and select Ultrasonic Sensor. For port,
select 2. For distance, select < eight inches.
Figure 12. Add a compare block from the data palette. Select
<. Connect a data wire from Value to A, and for B, type in 10.
SERVO 02.2011 45