Datasheet
Chapter 2: EEPROM Tricks and Program Tips · Page 67
CASE 1
DEBUG "one"
CASE 2
DEBUG "two"
CASE 3
DEBUG "three"
CASE 4
DEBUG "four"
CASE 5
DEBUG "five"
ENDSELECT
ENDIF
END ' End program
Strategy Tip
Your SumoBot programs could use this mode argument any number of ways. For example,
it might use SELECT...CASE to choose between different kinds of navigation routines that
search for opponents. On the other hand, it might just select something like a frequency to
use to make the SumoBot's IR object detectors more nearsighted, or a different number of
pulses for turning in place in the ring.
Example Program: PushbuttonMode.bs2
√ Enter, save, and run PushbuttonMode.bs2.
√ Press and hold the pushbutton as you press and release the Reset Button.
√ Wait until the speaker beeps three consecutive times before letting go of the
pushbutton.
√ Verify that the Debug Terminal indicates mode 3 has been selected.
√ Repeat and try selecting different modes.
' -----[ Title ]--------------------------------------------------------------
' Applied Robotics with the SumoBot - PushbuttonMode.bs2
' {$STAMP BS2} ' Target = BASIC Stamp 2
' {$PBASIC 2.5} ' Language = PBASIC 2.5
' -----[ I/O Definitions ]---------------------------------------------------
pbSense PIN 6 ' Pushbutton connected to P6
LedSpeaker PIN 5 ' LED/speaker connected to P5
' -----[ Variables ]----------------------------------------------------------
temp VAR Word ' Temporary variable
counter VAR Byte ' Loop counting variable.