Parallax Boe-Bot Student Manual page 237

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

Advertisement

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}
' {$PBASIC 2.5}
DEBUG "Program Running!"
' -----[ Variables ]----------------------------------------------------------
' Declare variables for storing measured RC times of the
' left & right photoresistors.
timeLeft
VAR
timeRight
VAR
average
VAR
difference
VAR
' -----[ 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
GOSUB Average_And_Difference
GOSUB Navigate
LOOP
' -----[ Subroutine - Test_Photoresistors ]-----------------------------------
Test_Photoresistors:
HIGH 6
PAUSE 3
RCTIME 6,1,timeLeft
HIGH 3
PAUSE 3
RCTIME 3,1,timeRight
RETURN
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 223
Word
Word
Word
Word
' Replace 351 and 7 with your own values.
' Stamp directive.
' PBASIC directive.
' Left RC time measurement.
' Right RC time measurement.

Advertisement

Table of Contents
loading

Table of Contents