Download Print this page

Parallax 29115 Manual page 17

Line follower module

Advertisement

' -----[ Initialization ]-------------------------------------------------------
'
Run_Check:
READ RstValue, temp
temp = ~temp
WRITE RstValue, temp
IF (temp) THEN Initialize
No_Run:
END
Initialize:
PAUSE 500
OutL = %01111100
DirL = %01111100
lastBits = %00100
onCourse = No
' -----[ Main Code ]------------------------------------------------------------
'
Main:
GOSUB Read_Line_Follower
IF (lfBits <> %00100) THEN Check_End
onCourse = Yes
Check_End:
IF (lfBits <> %11111) THEN Steer_Robot
IF (onCourse = No) THEN Straight
IF (lastBits <> %00000 ) THEN At_End
Steer_Robot:
steer = NCD lfBits
BRANCH steer,[Off_Line, Hard_Right, Right, Straight, Left, Hard_Left]
Save_Last:
lastBits = lfBits
GOTO Main
At_End:
PULSOUT LMotor, MStop
PULSOUT RMotor, MStop
Dirs = 0
WRITE RstValue, 0
END
' -----[ Subroutines ]----------------------------------------------------------
'
Read_Line_Follower:
lfBits = 0
FOR ledPos = 2 TO 6
OutL.LowBit(ledPos) = LEDon
PAUSE 1
lfBits.LowBit(ledPos) = In9 ^ LFmode
OutL = OutL | %01111100
NEXT
lfBits = lfBits >> 2
RETURN
Parallax, Inc. • Parallax Line Follower (#29115) • 12/2001
' get reset value
' invert bits
' write inverted bits back
' run if inverted > 0
' low power mode
' allow hand to release
' all LF LEDs off
' make pins outputs
' assume straight
' we haven't run course yet
' read the Line Follower
' check for middle sensor
' -- has been on the course
' keep steering if not at end
' still at start
' verify end of course
' get highest "on" bit
' save last reading
' stop motors
' turn off outputs
' run again after Reset press
' clear last reading
' turn the LED on
' allow sensor to read
' record the sensor reading
' turn LEDs off
' shift bits to zero index
Page 16

Advertisement

loading