Datasheet

Page 130ยท Applied Robotics with the SumoBot
irLS VAR sensors.BIT3 ' State of Left Side IR
irLF VAR sensors.BIT2 ' State of Right Side IR
irRF VAR sensors.BIT1 ' State of Right Front IR
irRS VAR sensors.BIT0 ' State of Right Side IR
The best thing about this arrangement is that no other changes in the program have to be
made. The program will still function normally, and you can display each bit value as
before.
โˆš Save TestAllSensorsYourTurn.bs2 as SensorsWithFlagsByte.bs2.
โˆš Modify the variable declarations as explained in this activity.
โˆš Test the program and verify that it still works the same.
Your Turn - Working with the Sensors Byte
Here is an alternate Initialization and Main Routine you can try to see how a byte can
show you different patterns of bits (1s and 0s). A
DEBUG command in the Initialization
builds a display heading to label each bit in the sensors variable, with a reference to the
sensor whose status that bit stores. Then a
DO...LOOP in the Main Routine constantly
updates the value of the
sensors variable, and displays in a second DEBUG command.
' -----[ Initialization ]----------------------------------------------
GOSUB Calibrate_Qtis ' Determine b/w threshold
' Display heading
DEBUG CLS, " PB", CR, ' Pushbutton
" |QTI",CR, ' QTI line sensors
" |||IROD",CR, ' Infrared Object Detectors
" |||||||",CR,
CR, ' Sensors byte goes here
" |||||||", CR,
" LRLLRR", CR, ' Left/right
" FFSFFS" ' Front/side
' -----[ Main Routine ]------------------------------------------------
DO ' DO...LOOP repeats indefinitely
GOSUB Read_Line_Sensors ' Look for lines
GOSUB Read_Object_Detectors ' Look for objects
GOSUB Read_Pushbutton ' Check pushbutton
DEBUG CRSRXY, 0, 4, BIN8 sensors ' Display Sensors Variable
PAUSE 100 ' Delay for slower PCs
LOOP