Datasheet
Page 66ยท Applied Robotics with the SumoBot
has still not been released, the outer loop repeats again, the inner loop beeps three times,
and so on.
' -----[ Subroutine - Mode_Select ]------------------------------------
' Selects mode of operation
Mode_Select:
DEBUG CR, ' Display user instructions
CR, "Release pushbutton after",
CR, "number of beeps to select",
CR, "mode (1 to 5)."
FOR temp = 1 TO 5 ' Cycle 5 times
FOR counter = 1 TO temp ' temp beeps, 1/second
PAUSE 100
FREQOUT LedSpeaker, 100, 4000
NEXT
PAUSE 1000 ' 1 second between beeps
IF pbSense = 0 THEN ' Button released?
WRITE ModeSelect, temp ' Record mode to EEPROM
EXIT ' Exit FOR...NEXT loop
ENDIF
NEXT
RETURN
The Main Routine checks to find out which mode was selected with the command READ
ModeSelect, temp
. An IF...THEN statement checks to see if the mode argument is
zero, which indicates that a mode was not selected. In this case, more instructions are
displayed in the Debug Terminal. The
ELSE condition features a DEBUG command and
SELECT...CASE code block that displays the mode.
' -----[ Main Routine ]------------------------------------------------
ModeTest:
READ ModeSelect, temp ' Fetch mode from EEPROM
IF temp = 0 THEN ' Mode = 0 -> no mode selected
DEBUG CR, "No mode selected",
CR, "Hold down pushbutton",
CR, "then press/release",
CR, "Reset button."
ELSE ' mode <> 0 -> display mode
DEBUG CR, CR,
"Operating in mode ", CR ' Mode Message
SELECT temp ' Select mode value to display