Parallax Boe-Bot Student Manual page 280

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

Advertisement

Page 266 · Robotics with the Boe-Bot
detectors read "no object" for brief moments, but this is not reason enough to
give up the chase.
' Robotics with the Boe-Bot - SumoBoeBot.bs2
' Search for object, lock onto it and push it.
' {$STAMP BS2}
' {$PBASIC 2.5}
irDetectLeft
irDetectRight
pulseLeft
pulseRight
' -----[ Initialization ]----------------------------------------------
DEBUG "Program Running!"
FREQOUT 4, 2000, 3000
' -----[ Main Routine ]------------------------------------------------
Main:
' Spin around slowly until an object is spotted
DO
PULSOUT 13, 790
PULSOUT 12, 790
PAUSE 15
GOSUB Check_IRs
LOOP UNTIL (irDetectLeft = 0) OR (irDetectRight = 0)
' Now figure out exactly where the object is and go toward it
DO
' Object in both detectors -- go forward
IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
pulseLeft =
pulseRight = 650
' Object on left - go left
ELSEIF (irDetectLeft = 0) THEN
pulseLeft =
pulseRight = 650
' Object on right - go right
ELSEIF (irDetectRight = 0) THEN
pulseLeft =
pulseRight = 850
' No object -- go forward anyway, because the detectors will
ELSE
pulseLeft =
pulseRight = 650
VAR
Bit
VAR
Bit
VAR
Word
VAR
Word
850
650
850
850
' Left IR reading
' Right IR reading
' pulse values for servos
' Signal start/reset.
' Rotate slowly
' 5 ms for detectors
' While looking for object
' Forward
' Left toward object
' Right toward object
' momentarily show
' "no object" as the
' Boe-Bot is adjusting

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Boe-Bot and is the answer not in the manual?

Questions and answers

Table of Contents

Save PDF