Datasheet
Page 194· Applied Robotics with the SumoBot
maneuver = Backward
GOSUB Servos_And_Sensors
NEXT
FOR counter = 1 TO 15 ' Turn right
maneuver = RotateRight
GOSUB Servos_And_Sensors
NEXT
RETURN
There was one small problem that had to be corrected before the program would run
properly. The last command in the initialization routine had to be changed from
GOTO Look_About ' Start mid search pattern
to
GOSUB Look_About ' Was Goto Look_About
The symptoms of this tiny coding mistake can be pretty discouraging. The SumoBot
does its 5 second delay, then looks left, then looks right, then does nothing more...
Here's why - the
Look_About label is now in the Search_Pattern subroutine. GOTO
Look_About sends the program to the Look_About label, and the program executes
commands until it gets to
RETURN. Since there was no GOSUB command before the
RETURN command, the BASIC Stamp sends the program to its beginning. By connecting
the SumoBot to the programming cable, the problem becomes clear, since the SumoBot
does a couple of moves, and then displays "Press/Release Reset button..." That's an
indication that the program is restarting, and the two most likely causes are tired batteries,
or a
RETURN command without a GOSUB.
Example Program: SumoWrestler.bs2
Did you skip ahead to get here? If you skipped any thing in Chapter 3 or 4, go back
and do it now.
The programs that follow are dependent upon the sensor circuits built, tested and calibrated
in the previous activities in Chapter 3 and 4.
√ Examine SumoWrestler.bs2 and make sure the Main Routine and navigation
state subroutines make sense to you.
√ Make sure to substitute your
IrFreq constant from Chapter 3, Activity #1 in
place of the
IrFreq constant in SumoWrestler.bs2. Use the one that most