Datasheet

Page 210· Applied Robotics with the SumoBot
Try it in the practice ring with the 3-position power switch set to 2.
Start your test SumoBot with its opponent on the right and watch the LED to see
if you can discern when it detects its opponent.
After you are done with this test, make sure to either comment the
IF...THEN
statement by placing an apostrophe to the left of it, or just delete it. Otherwise,
you will get incorrect results from the next test!
Did the SumoBot catch a glimpse of its opponent or not? Sometimes the LED might
stay on too briefly to actually see. If you want to catch the event, simply remove the ELSE
condition from the IF...THEN statement. It will cause the LED to turn on and stay on the
first time the event you are testing occurs.
IF irRS = 1 THEN HIGH LedSpeaker
This statement is also really good for determining whether your IR object detectors
are oversensitive and detecting far-off objects. Simply place the SumoBot in an empty
ring and let it do its search pattern. If the LED comes on, the detector saw something it
wasn't supposed to.
Testing the Subroutine's Looping Code
Next question: "... is there a problem with the looping code inside the
Track_Side_Right_Object subroutine?" One effective way to test this is to put a
TOGGLE LedSpeaker command inside the DO...LOOP in the
Track_Side_Right_Object subroutine. It makes the LED flicker and the speaker click
rapidly as the loop repeats. To keep from leaving the LED on after the subroutine is
finished, it's a good idea to also add a
LOW LedSpeaker command right before the
RETURN command.
Remember to first remove the test code from the
Servos_And_Sensors
subroutine.
Modify the
Track_Side_Right_Object subroutine in CompCodeLedTest.bs2
as shown here.
' -----[ Subroutine - Track_Side_Right_Object ]-------------------------------
Track_Side_Right_Object:
DO UNTIL irRF = 1 OR irLF = 1 ' Rotate right
TOGGLE LedSpeaker ' <--- Add
maneuver = RotateRight