EasyManua.ls Logo

Parallax Boe-Bot - Page 313

Parallax Boe-Bot
360 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 8: Robot Control with Distance Detection · Page 299
PAUSE 20
NEXT
ENDIF
' That's it. At this point the Boe-Bot should have turned 90 degrees
' to follow the intersection. Continue following the black line.
RETURN
Check_For_Intersection:
' Keep track of no. of pulses vs the forward pulses. If there are less
' than 30 forward pulses per total of 60 pulses, robot is likely stuck
' at an intersection.
isStuck = 0 ' Initialze Boolean variable
numPulses = numPulses + 1 ' Count total pulses sent
SELECT numPulses
CASE < 60
IF (pulseLeft > CenterPulse) THEN
fwdPulses = fwdPulses + 1 ' Count foward pulses
ENDIF ' (forward is any pulse > 750)
CASE = 60 ' If we have sent 60 pulses
IF (fwdPulses < 30) THEN ' how many were forward?
isStuck = 1 ' If < 30, robot is stuck
ENDIF
CASE > 60
numPulses = 0 ' Reset counters back to zero
fwdPulses = 0 ' (Could reset in =60 case but
ENDSELECT ' it spoils cool Make_Noise)
RETURN
Make_Noise:
' Makes an increasing tone, proportional to number of forward pulses
FOR counter = 1 TO fwdPulses STEP 3
FREQOUT 4, 100, 3800 + (counter * 10)
NEXT
RETURN
Update_LEDs:
' Use LEDs to indicate whether detectors are seeing black or white.
' White = Off, Black = On. Black is a distance reading > or = 4 .
IF (distanceLeft >= 4) THEN HIGH LeftLED ELSE LOW LeftLED
IF (distanceRight >= 4) THEN HIGH RightLED ELSE LOW RightLED
RETURN
Stop_Quickly:
' This stops the wheels so the Boe-Bot does not "coast" forward.
PULSOUT 13, 750

Table of Contents

Other manuals for Parallax Boe-Bot