Parallax Boe-Bot Student Manual page 247

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

Advertisement

Chapter 6: Light Sensitive Navigation with Photoresistors · Page 233
"FlashlightControlledBoeBot.bs2" and "RoamingTowardTheLight.bs2". A
sample solution is shown below.
' -----[ Title ]-------------------------------------------------------
' Robotics with the Boe-Bot - AvoidBlackSpots.bs2
' Boe-Bot avoids black pieces of paper.
' {$STAMP BS2}
' {$PBASIC 2.5}
' -----[ Constants ]---------------------------------------------------
LeftWhite
CON
RightWhite
CON
LeftBlack
CON
RightBlack
CON
LeftAvg
CON
RightAvg
CON
' -----[ Variables ]---------------------------------------------------
timeLeft
VAR
reading
timeRight
VAR
reading
' -----[ Initialization ]----------------------------------------------
FREQOUT 4, 2000, 3000
' -----[ Main Routine ]------------------------------------------------
DO
GOSUB Test_Photoresistors
GOSUB Navigate
LOOP
' -----[ Subroutines --------------------------------------------------
Test_Photoresistors:
HIGH 6
Measurement.
PAUSE 3
RCTIME 6,1,timeLeft
HIGH 3
measurement.
PAUSE 3
RCTIME 3,1,timeRight
RETURN
Navigate:
16
33
26
45
LeftWhite + LeftBlack / 2
RightWhite + RightBlack / 2
Word
Word
' Stamp directive
' PBASIC directive.
' Left photoresistor
' Right photoresistor
' Left RC time
' Right RC time

Advertisement

Table of Contents
loading

Table of Contents