Datasheet

Chapter 5: Debugging and Datalogging · Page 211
GOSUB Servos_And_Sensors
LOOP
LOW LedSpeaker ' <--- Add
RETURN
Run the modified program with the SumoBot's 3-position power switch set to 1.
Make sure no objects are in view of the SumoBot's other three object detectors.
Wave your hand in front of the right object detector.
Verify that the LED blinks and the speaker clicks rapidly until you wave your
hand in front of one of the front IR detectors.
Try it in the practice ring with the 3-position power switch set to 2.
Start your test SumoBot, again, with its opponent on the right.
Press/release the Reset button, and verify that the LED flickers and the speaker
clicks as it rounds on its opponent.
Leave the LED code where it is for the next test.
If the LED doesn't flicker, there may be an object in front of the SumoBot, or there could
be a branching problem. To test to find out if there is an object in front of the Boe-Bot,
try moving the LED test to the
Go_Forward subroutine. If the LED flickers constantly,
then it confirms the problem. This test would also have to be repeated for the
Track_Front_Left_Object and Track_Front_Right_Object subroutines.
Testing for Branching Problems
IF...THEN, GOTO, GOSUB, and RETURN are all examples of branching commands. They
can cause the code to skip from one "branch" of the program to another. If a program has
a branching problem, it would be because a command is telling the program to skip to a
place you don't want it to go to.
Let's say this is the real bug in the program is in the Main Routine. In the code block
below, the programmer typed
GOSUB Track_Side_Left_Object twice by accident. It's
the correct response to the first
ELSEIF, but the second ELSEIF code block should call the
Track_Side_Right_Object subroutine.