Datasheet

Chapter 5: Debugging and Datalogging · Page 215
Enter, save, and run Compiler directives.bs2 and check the program's behavior
against your predictions.
Change
#DEFINE LED_MODE = 1 to #DEFINE LED_MODE = 0.
Predict how the program will behave the next time it is downloaded to the
BASIC Stamp.
Run the program, and again test your predictions.
Repeat for the other four combinations of values that you can set
LED_MODE and
DEBUG_MODE equal to.
' -----[ Title ]--------------------------------------------------------------
' Applied Robotics with the SumoBot - CompilerDirectives.bs2
' How to use compiler directives to select which code blocks to run.
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ Compiler Definitions ]-----------------------------------------------
#DEFINE LED_MODE = 1
#DEFINE DEBUG_MODE = 2
' -----[ I/O Definitions ]----------------------------------------------------
#IF LED_MODE = 1 #THEN
LedSpeaker PIN 5
#ENDIF
' -----[ Variables ]----------------------------------------------------------
counter VAR Word
' -----[ Initialization ]-----------------------------------------------------
DEBUG CLS, "Program running...", CR, CR
#SELECT DEBUG_MODE
#CASE 0
DEBUG "DEBUG_MODE is zero."
#CASE 1
DEBUG "DEBUG_MODE is one."
#CASE 2
DEBUG "DEBUG_MODE is two."
#ENDSELECT
DEBUG CR, CR
' -----[ Main Routine ]-------------------------------------------------------