Datasheet
Page 212· Applied Robotics with the SumoBot
√ Modify the main routine so that this bug is incorporated.
ELSEIF irLS = 1 THEN ' Left side?
GOSUB Track_Side_Left_Object ' State = track side left obj.
ELSEIF irRS = 1 THEN ' Right side?
GOSUB Track_Side_Left_Object ' State = track side right obj.
With this particular bug, the LED would not turn on in the previous test indicating that
the code just wasn't making it there. Assuming you have already ruled out the possibility
of the front IR object detectors seeing something, the next thing to examine is a
branching problem.
√ Start by repeating the
TOGGLE LedSpeaker test in the
Track_Side_Right_Object subroutine. The LED should not respond to
waving your hand in front of the SumoBot's side-right object detector because
the subroutine never gets called.
√ Remove the
TOGGLE LedSpeaker command and LOW LedSpeaker commands
from the
Track_Side_Right_Object subroutine.
√ Add this
IF...THEN statement to the DO...LOOP in the Main Routine.
DO
IF irRS = 1 THEN HIGH LedSpeaker ELSE LOW LedSpeaker ' <--- Add
IF qtiLF = 1 THEN ' Left qti sees line?
GOSUB Avoid_Tawara_Left ' State = avoid left tawara
When you wave your hand in front of the right IR object detector, the LED should turn
on. When you wave your hand in front of one of the front IR detectors, the LED should
turn off again. That indicates that a navigation subroutine is getting called, it's just that
it's not the right one. So now, check which one, and the problem will be found.
ACTIVITY #2: CONDITIONAL COMPILING
Commenting and uncommenting lines of test routines can be time consuming and leaves
the door open for a lot of mistakes. Conditional compiler directives can help, and this
activity demonstrates how.
Compiler Directives
Here is a new section, Compiler Definitions. These #DEFINE directives do not get
downloaded to the BASIC Stamp. Instead, the BASIC Stamp Editor just makes a note to