EasyManua.ls Logo

Parallax Boe-Bot - Page 247

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 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} ' Stamp directive
' {$PBASIC 2.5} ' PBASIC directive.
' -----[ Constants ]---------------------------------------------------
LeftWhite CON 16
RightWhite CON 33
LeftBlack CON 26
RightBlack CON 45
LeftAvg CON LeftWhite + LeftBlack / 2
RightAvg CON RightWhite + RightBlack / 2
' -----[ Variables ]---------------------------------------------------
timeLeft VAR Word ' Left photoresistor
reading
timeRight VAR Word ' Right photoresistor
reading
' -----[ Initialization ]----------------------------------------------
FREQOUT 4, 2000, 3000
' -----[ Main Routine ]------------------------------------------------
DO
GOSUB Test_Photoresistors
GOSUB Navigate
LOOP
' -----[ Subroutines --------------------------------------------------
Test_Photoresistors:
HIGH 6 ' Left RC time
Measurement.
PAUSE 3
RCTIME 6,1,timeLeft
HIGH 3 ' Right RC time
measurement.
PAUSE 3
RCTIME 3,1,timeRight
RETURN
Navigate:

Table of Contents

Other manuals for Parallax Boe-Bot