Datasheet
Page 106· Applied Robotics with the SumoBot
DEBUG "Black"
ENDIF
PAUSE 100 ' Delay for slower PCs
LOOP
' -----[ Subroutine - Read_Line_Sensors ]-------------------------------------
Read_Line_Sensors:
HIGH qtiPwrLeft ' Turn left QTI on
HIGH qtiSigLeft ' Discharge capacitor
PAUSE 1
RCTIME qtiSigLeft, 1, qtiLeft ' Measure charge time
LOW qtiPwrLeft ' Turn left QTI off
HIGH qtiPwrRight ' Turn right QTI on
HIGH qtiSigRight ' Discharge capacitor
PAUSE 1
RCTIME qtiSigRight, 1, qtiRight ' Measure charge time
RETURN
Your Turn - QTI Navigation Decisions
Incorporating navigation can be as simple as an IF...THEN statement that calls
subroutines that perform preprogrammed maneuvers. Instead of subroutine calls, the
code block below uses
DEBUG commands to display what action should be taken.
√ Save QtiSelfCalibrate.bs2 as QtiSelfCalibrateYourTurn.bs2
√ Remove the two
IF...THEN...ENDIF code blocks, and replace them with this:
' Indicate maneuver that should be taken based on QTI readings
DEBUG CR, "Maneuver",
CR, "-----------", CR
IF qtiLeft < qtiThreshold AND qtiRight < qtiThreshold THEN
DEBUG "Avoid tawara - both"
ELSEIF qtiLeft < qtiThreshold THEN
DEBUG "Avoid tawara - left"
ELSEIF qtiRight < qtiThreshold THEN
DEBUG "Avoid tawara - right"
ELSE
DEBUG "search"
ENDIF
DEBUG CLREOL