useful for controlling the SumoBot in a competition without fumbling for the actual
power switch.
The code at Reset reads a byte from the BASIC Stamp's EEPROM; located at the address
called RunStatus . When the program is first downloaded to the BASIC Stamp, the value
stored in RunStatus will be $00 (don't run). The READ instruction is used to bring this
value into the variable temp , then temp is inverted (to $FF), and finally, WRITE is used to
put it back to the EEPROM for the next reset cycle. Next, the value of temp is tested for
greater than zero. If this condition is true, the program is halted with END (which puts the
BASIC Stamp goes into low-power mode), otherwise it continues to the Start_Delay
code.
The routine called Start_Delay satisfies a requirement of Mini-Sumo competition rules.
The rules state that the robot must not start until five seconds after the command is given
by the judge. This code is very simple: it lights the LED to show that the SumoBot is
preparing to start and inserts a five second PAUSE . At the end of the delay, the LED will
be extinguished and the SumoBot will start moving.
The heart of the program begins at Main. The first step is to read the sensors with the
Read_Line_ Sensors subroutine. With the QTI sensor data, the SumoBot is moved using
the same logic developed earlier:
L
0
0
1
1
BRANCH takes care of routing the program to the right code section based on the QTI
inputs. As with SELECT-CASE , we're using BRANCH to replace several IF-THEN
comparisons. It should be clear that this is a cleaner approach than IF-THEN .
The only thing that might not be clear is that there is no delay (20 ms) in the Go_Fwd
routine. It isn't needed when the SumoBot is in the middle of the ring (not touching the
border line) because reading the QTI sensors consumes enough time that the delay is not
necessary.
Chapter 3: SumoBot Sensors and Border Detection · Page 33
R
Action
0
Move forward
1
Spin to left
0
Spin to right
1
Back up and turn around
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers