Datasheet
Chapter 2: EEPROM Tricks and Program Tips ยท Page 55
LOOP
ENDIF
DEBUG CR, "All done!"
END
ACTIVITY #3: PROGRAM ON/OFF WITH RESET
It's really handy to be able to start and halt a sumo wrestling program by pressing and
releasing the SumoBot's Reset button. This technique was first introduced in Chapter 3
of the SumoBot book. It makes it possible to press and release the Reset button to toggle
between two separate program modes: wrestle, and wait for reset.
Reset Subroutine for the New Program Design
The new Reset subroutine will still depend on an EEPROM byte with the Symbol name
RunStatus. This DATA directive will write 0 to the RunStatus address when the
program is downloaded.
' -----[ EEPROM Data ]--------------------------------------------------------
RunStatus DATA 0 ' Run status EEPROM byte
The Reset routine from the SumoBot text was a code block in the program's
Initialization section. The programs in this text will instead call a subroutine named
Reset from the Initialization routine.
' -----[ Initialization ]-----------------------------------------------------
GOSUB Reset ' Wait for Reset press/release
GOSUB Start_Delay ' 5 Second delay
' -----[ Main Routine ]-------------------------------------------------------
ResetTest:
DEBUG CR, "Done!" ' Verify we made it to main.
END
Here is the new Reset subroutine. It uses the odd/even number technique introduced in
Activity #1 of this chapter. In this subroutine, if
temp is odd (after 1 has been added to
it), it displays the "Press/release Reset button" message, and then ends the program. If