Parallax Boe-Bot Student Manual page 312

Hide thumbs Also See for Boe-Bot:
Table of Contents

Advertisement

Page 298 · Robotics with the Boe-Bot
GOSUB Update_LEDs
' Calculate proportional output and move accordingly.
pulseLeft =
pulseRight = SetPoint - distanceRight * Kpr + CenterPulse
GOSUB Send_Pulse
GOSUB Check_For_Intersection
IF (isStuck = 1) THEN
GOSUB Make_Noise
GOSUB Navigate_Intersection
ENDIF
LOOP
' -----[ Subroutines ]-------------------------------------------------
Navigate_Intersection:
'
Go forward until both sensors read white, through the intersection.
DO
pulseLeft = 850:
GOSUB Send_Pulse
GOSUB Get_Ir_Distances
GOSUB Update_LEDs
LOOP UNTIL (distanceLeft <=2) AND (distanceRight <=2)
GOSUB Stop_Quickly
' Now back up until one detector sees the black.L & R turn will see
' black on one detector.3- or 4-way will see both black, turn toward
' whichever the bot sees first (random).
DO
pulseLeft = 650:
GOSUB Send_Pulse
GOSUB Get_Ir_Distances
GOSUB Update_LEDs
LOOP UNTIL (distanceLeft >=4) OR (distanceRight >=4)
GOSUB Stop_Quickly
' Make 90 degree turn in direction of the detector which sees black
IF (distanceLeft >=4) THEN
FOR counter = 1 TO Turn90Degree
PULSOUT 13, 750
PULSOUT 12, 650
PAUSE 20
NEXT
ELSEIF (distanceRight >=4) THEN
FOR counter = 1 TO Turn90Degree
PULSOUT 13, 850
PULSOUT 12, 750
' Indicate white/black line
SetPoint - distanceLeft
' Are we stuck at intersection?
' Audible indication
' Navigate through it
pulseRight = 650
pulseRight = 850
* Kpl + CenterPulse
' Forward
' Don't coast forward
' Backward
' Don't coast backward
' Left detector reads black
' Turn 90 degrees left
' without proportional control
' so use PAUSE 20
' Right detector reads black
' Turn 90 degrees right

Advertisement

Table of Contents
loading

Table of Contents