EasyManua.ls Logo

Parallax Boe-Bot - Building and Testing the IR Pairs

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 223
Also try placing your Boe-Bot in a room that is poorly lit, but that has light
streaming in through a doorway from an adjacent brightly lit room or hallway.
See if the Boe-Bot can successfully find its way out the door.
' -----[ Title ]--------------------------------------------------------------
' Robotics with the Boe-Bot - RoamingTowardTheLight.bs2
' Boe-Bot roams, and turns away from dark areas in favor of brighter areas.
' {$STAMP BS2} ' Stamp directive.
' {$PBASIC 2.5} ' PBASIC directive.
DEBUG "Program Running!"
' -----[ Variables ]----------------------------------------------------------
' Declare variables for storing measured RC times of the
' left & right photoresistors.
timeLeft VAR Word
timeRight VAR Word
average VAR Word
difference VAR Word
' -----[ Initialization ]-----------------------------------------------------
FREQOUT 4, 2000, 3000
' -----[ Main Routine ]-------------------------------------------------------
DO
GOSUB Test_Photoresistors
' For mismatched photoresistors, use Appendix F, uncomment and use next line.
' timeLeft = (timeLeft */ 351) + 7 ' Replace 351 and 7 with your own values.
GOSUB Average_And_Difference
GOSUB Navigate
LOOP
' -----[ Subroutine - Test_Photoresistors ]-----------------------------------
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

Table of Contents

Other manuals for Parallax Boe-Bot