Parallax Boe-Bot Student Manual page 311

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

Advertisement

intersection is a 3-way or 4-way intersection, the Boe-Bot will arbitrarily turn in
the direction that black is first detected. A constant,
to tune the 90 degree turn. Some audible and visual indicators are included,
which aid in troubleshooting and understanding what the Boe-Bot is seeing and
deciding, as well as adding a bit of personality and fun.
' -----[ Title ]-------------------------------------------------------
' Robotics with the Boe-Bot - IntersectionsBoeBot.bs2
' Navigate 90 degree left/right, 3-way, and 4-way intersections.
' Based on StripeFollowingBoeBot.bs2
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
' -----[ Constants ]---------------------------------------------------
Kpl
CON
Kpr
CON
SetPoint
CON
CenterPulse
CON
Turn90Degree
CON
RightLED
PIN
LeftLED
PIN
' -----[ Variables ]---------------------------------------------------
freqSelect
VAR
irFrequency
VAR
irDetectLeft
VAR
irDetectRight
VAR
distanceLeft
VAR
distanceRight
VAR
pulseLeft
VAR
pulseRight
VAR
numPulses
VAR
fwdPulses
VAR
counter
VAR
isStuck
VAR
' -----[ Initialization ]----------------------------------------------
FREQOUT 4, 2000, 3000
' -----[ Main Routine ]------------------------------------------------
DO
GOSUB Get_Ir_Distances
Chapter 8: Robot Control with Distance Detection · Page 297
' Stamp directive.
' PBASIC directive.
35
' Left proportional constant
-35
' Right proportional constant
3
' 0-1 is White, 4-5 is Black
750
30
' Pulses needed for 90 turn
1
' LED Indicators
10
Nib
' Sweep through 5 frequencies
Word
' Freq sent to IR emitter
Bit
' Store results from detectors
Bit
Nib
' Calculate distance zones
Nib
Word
' Servo pulseWidths
Word
Byte
' Count total pulses
Byte
' Count forward pulses
Byte
Bit
' Boolean variable,is bot stuck?
' Read IR sensors
, is provided
Turn90Degree

Advertisement

Table of Contents
loading

Table of Contents