Datasheet

Chapter 2: EEPROM Tricks and Program Tips ยท Page 53
DEBUG CRSRX, 0, DEC5 temp, CRSRX, 12
IF temp > compare THEN
DEBUG "greater than"
ELSEIF temp < compare THEN
DEBUG "less than"
ELSE
DEBUG "equal to"
ENDIF
DEBUG CR
counter = counter + 2
LOOP
ENDIF
Example Program: ThreeVariablesManyJobs.bs2
โˆš Enter, save, and run ThreeVariablesManyJobs.bs2.
โˆš Try feeding the program the same values shown in Figure 2-3 first. Then re-run
the program and use your own values.
โˆš Review the program. Pay special attention to the different kinds of jobs the
program does and how it uses and reuses
temp and counter so many times.
' Applied Robotics with the SumoBot - ThreeVariablesManyJobs.bs2
' {$STAMP BS2}
' {$PBASIC 2.5}
' Variable Declarations
counter VAR Byte
temp VAR Word
compare VAR Word
' Set aside EEPROM storage space
Values DATA (40)
Threshold DATA Word 0
' Get threshold value and store it in EEPROM
DEBUG CLS,
"Enter a threshold value", CR,
"between 100 and 1000", CR,
">"
DEBUGIN DEC temp
WRITE Threshold, Word temp