Datasheet

Chapter 4: Navigation Tips ยท Page 197
GOSUB Reset ' Wait for Reset press/release
GOSUB Start_Delay ' 5 Second delay
GOSUB Calibrate_Qtis ' Determine b/w threshold
GOSUB Look_About ' Was Goto Look_About
' -----[ Main Routine ]-------------------------------------------------------
DO
IF qtiLF = 1 THEN ' Left qti sees line?
GOSUB Avoid_Tawara_Left ' State = avoid left tawara
ELSEIF qtiRF = 1 THEN ' Right qti sees line?
GOSUB Avoid_Tawara_Right ' State = avoid right tawara
ELSEIF irLF = 1 AND irRF = 1 THEN ' Both? Lunge forward
GOSUB Go_Forward ' State = Go forward
ELSEIF irLF = 1 THEN ' Just left?
GOSUB Track_Front_Left_Object ' State = Track front left obj.
ELSEIF irRF = 1 THEN ' Just right?
GOSUB Track_Front_Right_Object ' State = Track front right obj.
ELSEIF irLS = 1 THEN ' Left side?
GOSUB Track_Side_Left_Object ' State = track side left obj.
ELSEIF irRS = 1 THEN ' Right side?
GOSUB Track_Side_Right_Object ' State = track side right obj.
ELSE ' Nothing sensed?
GOSUB Search_Pattern ' State = Search pattern
ENDIF
LOOP
' -----[ Subroutine - Reset ]-------------------------------------------------
Reset:
READ RunStatus, temp ' Byte @RunStatus -> temp
temp = temp + 1 ' Increment temp
WRITE RunStatus, temp ' Store new value for next time
IF (temp.BIT0 = 1) THEN ' Examine temp.BIT0
DEBUG CLS, "Press/release Reset", CR, ' 1 -> end, 0 -> keep going
"button..."
END
ELSE
DEBUG CR, "Program running..."
ENDIF
RETURN
' -----[ Subroutine - Start_Delay ]-------------------------------------------
Start_Delay: