Line Following using one photo resistor
We have a project in class that involves following a black piece of electrical tape on a white board through a course including curves. We are allowed to use only one photo resistor. I wrote the program below but for some reason once the robot goes off the edge of the tape and starts the searching commands, it goes to the right and the left okay but doesn't seem to be testing the photo resistor at the far right like it should.....it only reads after the search left and responds to the reading. I hope that made sense. The project is due tomorrow afternoon.......any suggestions?
' {$STAMP BS2}
' {$PBASIC 2.5}
time VAR Word
pulsecount VAR Byte
DO
GOSUB test_photoresistors
GOSUB navigate
LOOP
test_photoresistors:
HIGH 3
PAUSE 3
RCTIME 3, 1, time
RETURN
navigate:
IF (time > 70) THEN
PULSOUT 13, 800
PULSOUT 12, 700
ELSE
GOSUB searchright
GOSUB searchleft
ENDIF
PAUSE 10
RETURN
searchright:
FOR pulsecount = 0 TO 40
PULSOUT 13, 755
PULSOUT 12, 755
PAUSE 30
GOSUB test_photoresistors
NEXT
RETURN
searchleft:
FOR pulsecount = 0 TO 20
PULSOUT 13, 740
PULSOUT 12, 740
PAUSE 30
GOSUB test_photoresistors
NEXT
RETURN
' {$STAMP BS2}
' {$PBASIC 2.5}
time VAR Word
pulsecount VAR Byte
DO
GOSUB test_photoresistors
GOSUB navigate
LOOP
test_photoresistors:
HIGH 3
PAUSE 3
RCTIME 3, 1, time
RETURN
navigate:
IF (time > 70) THEN
PULSOUT 13, 800
PULSOUT 12, 700
ELSE
GOSUB searchright
GOSUB searchleft
ENDIF
PAUSE 10
RETURN
searchright:
FOR pulsecount = 0 TO 40
PULSOUT 13, 755
PULSOUT 12, 755
PAUSE 30
GOSUB test_photoresistors
NEXT
RETURN
searchleft:
FOR pulsecount = 0 TO 20
PULSOUT 13, 740
PULSOUT 12, 740
PAUSE 30
GOSUB test_photoresistors
NEXT
RETURN
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen