Datasheet
Page 216· Applied Robotics with the SumoBot
DO
DEBUG CRSRX, 0, ? counter
counter = counter + 1
#IF LED_MODE = 1 #THEN
DEBUG "LED state = ", BIN1 counter.BIT0, CRSRUP
TOGGLE LedSpeaker
PAUSE 200
#ELSE
DEBUG "LED_MODE disabled", CRSRUP
PAUSE 100
#ENDIF
LOOP
Your Turn - Conditionally Compiling LED Commands
In Activity #1, you inserted four different PBASIC commands to make the LED notify
you of certain events. One command was added to the Main Routine, another to the
Servos_And_Sensors subroutine, and two commands were added to the
Track_Side_Right_Object subroutine.
√ Reopen the CompCodeLedTest.bs2 from this chapter's activity #1
√ Insert a
#DEFINE LED_MODE declaration at the beginning of the program.
√ Nest the LED test commands into
#IF...#THEN blocks. Make sure that the test
for each compiles its code based on a different value of
LED_MODE, such as 1, 2,
and 3. Then, if you declare
LED_MODE to be 0, none of the LED test codes will
be compiled.
√ Test your program.
ACTIVITY #3: DEBUGGING PROBLEM BEHAVIORS
LED tests can provide a quick indication of what's happening in a certain place in a
SumoBot's program, but that's about all it can do. In other words, the scope of LED tests
tend to be somewhat limited.
This activity introduces a Debug Terminal diagnostic tool with a much broader scope.
You can use it to watch all the sensors, navigation states and maneuvers the SumoBot