28125 Parallax Inc, 28125 Datasheet - Page 237

TEXT ROBOTICS

28125

Manufacturer Part Number
28125
Description
TEXT ROBOTICS
Manufacturer
Parallax Inc
Datasheet

Specifications of 28125

Title
Robotics with the Boe-Bot
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
' -----[ 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
timeRight
average
difference
' -----[ Initialization ]-----------------------------------------------------
FREQOUT 4, 2000, 3000
' -----[ Main Routine ]-------------------------------------------------------
DO
' For mismatched photoresistors, use Appendix F, uncomment and use next line.
' timeLeft = (timeLeft */ 351) + 7
LOOP
' -----[ Subroutine - Test_Photoresistors ]-----------------------------------
Test_Photoresistors:
GOSUB Test_Photoresistors
GOSUB Average_And_Difference
GOSUB Navigate
HIGH 6
PAUSE 3
RCTIME 6,1,timeLeft
HIGH 3
PAUSE 3
RCTIME 3,1,timeRight
RETURN
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.
VAR
VAR
VAR
VAR
Word
Word
Word
Word
' Replace 351 and 7 with your own values.
' Stamp directive.
' PBASIC directive.
' Left RC time measurement.
' Right RC time measurement.

Related parts for 28125