EasyManua.ls Logo

Parallax Boe-Bot - Page 246

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...
Page 232 · Robotics with the Boe-Bot
' -----[ Title ]----------------------------------------------------------
' Robotics with the Boe-Bot - TestBlackWhiteLogic.bs2
' Calculate whether Boe-Bot is over black or white surface, and print.
' {$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
' -----[ Main Routine ]---------------------------------------------------
DO
GOSUB Test_Photoresistors
IF (timeLeft > LeftAvg) THEN
DEBUG CRSRXY, 0, 0, "Left Black "
ELSE
DEBUG CRSRXY, 0, 0, "Left White "
ENDIF
IF (timeRight > RightAvg) THEN
DEBUG CRSRXY, 13, 0, "Right Black", CR
ELSE
DEBUG CRSRXY, 13, 0, "Right White", CR
ENDIF
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
To develop a program that makes the Boe-Bot avoid the black sheets of paper,
the decision and navigation steps required are very similar to

Table of Contents

Other manuals for Parallax Boe-Bot