QTI line follower appkit documentation v2.0
Copyright © Parallax Inc. QTI LIne Follower AppKit (#28108) v2.0 3/23/2009 Page 6 of 6
Keep in mind that this is a bare-bones line
following example. Making it robust and
versatile is up to you. The Boe-Bot starts
maneuvers when it sees one of the cases
listed in the
SELECT...CASE statement.
This is convenient for a simple
demonstration program because the Boe-
Bot doesn't go anywhere when it is on an
all white or all black surface. It only starts
navigation when it detects a line. You can
add extra code, especially in the form of
CASE statements to deal with special
situations and more complex courses.
√ Try other courses to test the limits
of the program.
√ Try modifying the program to
solve courses that the unmodified
program could not solve.
√ Modify the program so that it
smoothes out the Boe-Bot's
responses to changes in the line's
direction. Your code should take
steps toward a maximum speed
each time it detects that a given
pattern is detected.
√ Detect intersections and make
random turns.
√ Challenge a friend, or set up a
Boe-Bot line following
competition.
' {$STAMP BS2}
' {$PBASIC 2.5}
' LineFollowWithCheckQtis.bs2
' Navigates based on values acquired with the
' Check_Qtis subroutine.
qtis VAR Nib ' black/white states
OUTB = %1111 ' Set OUTB bits to 1
DO ' Main DO...LOOP
GOSUB Check_Qtis ' Get QTI states
SELECT qtis ' Control servo
' speeds/directions
CASE %1000 ' Rotate right
PULSOUT 13, 650
PULSOUT 12, 650
CASE %1100 ' Pivot right
PULSOUT 13, 750
PULSOUT 12, 650
CASE %0100 ' Curve right
PULSOUT 13, 800
PULSOUT 12, 650
CASE %0110 ' Straight ahead
PULSOUT 13, 850
PULSOUT 12, 650
CASE %0010 ' Curve left
PULSOUT 13, 850
PULSOUT 12, 700
CASE %0011 ' Pivot left
PULSOUT 13, 850
PULSOUT 12, 750
CASE %0001 ' Rotate left
PULSOUT 13, 850
PULSOUT 12, 850
CASE ELSE ' Do nothing
PAUSE 3
ENDSELECT
LOOP
Check_Qtis:
' Result -> qtis variable.
' 0 means white surface
' 1 means black surface.
DIRB = %1111 ' P7..P4 -> output
PAUSE 0 ' Delay = 230 us
DIRB = %0000 ' P7..P4 -> input
PAUSE 0 ' Delay = 230 us
qtis = INB ' Store QTI outputs
' in INB
RETURN