Eddie Should Now Be Ready To Rock!
Download your program and give it a test. He should go forward full speed until he hits the edge of your arena, then
Figure 1. Start with an infinite outer loop and a light sensor
switch (uncheck "Flat View") from the flow palette, with a
"Move" command in the dark tab of the switch. Set the port to
3, and adjust the values based on your sensor readings.
Figure 2. Set motors C and B forward for an unlimited duration.
Figure 3. Click to the light side of the switch. Go to Edit > Define
Variables and create a number variable called LoopCount.
Then, from the data palette, drag in a variable block.
Figure 4. Select "LoopCount" and "Write."
Figure 5. Add a loop and set Control to Count. Count to 17. This
means that it will loop 17 times. We're going to break up the
back-up and turn into 17 smaller movements, and check the
ultrasonic sensor after each one. That way, if Eddie sees the
opponent robot mid-movement, he can react immediately.
Figure 6. Add a variable block inside the new loop; select
LoopCount and Read.
44 SERVO 02.2011