Datasheet

Chapter 2: EEPROM Tricks and Program Tips · Page 57
continues to the rest of the program. As you keep pressing the Reset button, the odd/even
pattern continues, as does the program's alternation between the "Press/release Reset..."
and "Program running..." messages.
Example Program: TestResetButton.bs2
Enter, save, and download TestResetButton.bs2.
Verify that it displays the "Press/release reset button..." message and ends the
program.
Press/release the Reset button. Verify that the program displays the message
"Program running...", beeps 5 times, then displays the message "Done!".
Press/release the Reset button a second time.
Verify that the program behaves the same as it did when you first downloaded it.
Press/release the Reset button a third time, and verify that it behaves the same
way it did the first time you did it.
Keep repeating a few more times to make sure the odd/even pattern continues.
' -----[ Title ]--------------------------------------------------------------
' Applied Robotics with the SumoBot - TestResetButton.bs2
' {$STAMP BS2} ' Target = BASIC Stamp 2
' {$PBASIC 2.5} ' Language = PBASIC 2.5
' -----[ I/O Definitions ]---------------------------------------------------
LedSpeaker PIN 5 ' P5 controls LED & speaker
' -----[ Variables ]----------------------------------------------------------
temp VAR Word ' Temporary variable
counter VAR Byte ' Loop counting variable.
' -----[ EEPROM Data ]--------------------------------------------------------
RunStatus DATA 0 ' Run status EEPROM byte
' -----[ 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.