FlashlightControlledBoeBot

FlashlightControlledBoeBot - ' DO D GOSUB...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
' -----[ Title ]-------------------------------------------------------------- ' Robotics with the Boe-Bot - FlashlightControlledBoeBot.bs2 ' Boe-Bot follows flashlight beam focused in front of it. ' ' {$Stamp bs2} ' Stamp directive. ' {$PBASIC 2.5} ' PBASIC directive. ' ' -----[ Constants ]---------------------------------------------------------- ' ' REPLACE THESE VALUES WITH THE VALUES YOU DETERMINED AND ENTERED INTO ' TABLE 6.1. ' LeftAmbient CON 108 RightAmbient CON 114 LeftBright CON 20 RightBright CON 22 R ' Average Scale factor ' LeftThreshold CON LeftBright + LeftAmbient / 2 * 5 / 8 RightThreshold CON RightBright + RightAmbient / 2 * 5 / 8 R ' -----[ Variables ]---------------------------------------------------------- ' ' Declare variables for storing measured RC times of the ' timeLeft VAR Word timeRight VAR Word t ' -----[ Initialization ]----------------------------------------------------- ' FREQOUT 4, 2000, 3000 F ' -----[ Main Routine ]-------------------------------------------------------
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ' DO D GOSUB Test_Photoresistors GOSUB Navigate LOOP L ' -----[ Subroutine - Test_Photoresistors ]-----------------------------------' Test_Photoresistors: T 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 ' -----[ Subroutine - Navigate ]----------------------------------------------' Navigate: N IF (timeLeft < LeftThreshold) AND (timeRight < RightThreshold) THEN PULSOUT 13, 850 ' Both detect flashlight beam, PULSOUT 12, 650 ' full speed forward. ELSEIF (timeLeft < LeftThreshold) THEN ' Left detects flashlight beam, PULSOUT 13, 700 ' pivot left. PULSOUT 12, 700 ELSEIF (timeRight < RightThreshold) THEN ' Right detects flashlight beam, PULSOUT 13, 800 ' pivot right. PULSOUT 12, 800 ELSE PULSOUT 13, 750 ' No flashlight beam, sit still. PULSOUT 12, 750 ENDIF PAUSE 20 ' Pause between pulses. RETURN...
View Full Document

This note was uploaded on 04/23/2010 for the course EECC 0306-201 taught by Professor Roymelton during the Spring '10 term at RIT.

Page1 / 2

FlashlightControlledBoeBot - ' DO D GOSUB...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online