RoamingPhotoresistorDividers

RoamingPhotoresistorDividers - GOSUB Back_Up ' shadow, back...

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 - RoamingPhotoresistorDividers.bs2 ' Boe-Bot detects shadows photoresistors voltage divider circuit and turns ' away from them. ' ' {$Stamp bs2} ' Stamp directive. ' {$PBASIC 2.5} ' PBASIC directive. ' ' -----[ Variables ]---------------------------------------------------------- ' pulseCount VAR Byte ' For. ..next loop counter. p ' -----[ Initialization ]----------------------------------------------------- ' FREQOUT 4, 2000, 3000 ' Start/restart signal. F ' -----[ Main Routine ]------------------------------------------------------- ' DO IF (IN6 = 0) AND (IN3 = 0) THEN ' Both photoresistors detects GOSUB Back_Up GOSUB Turn_Left ' (left twice). GOSUB Turn_Left ELSEIF (IN6 = 0) THEN ' Left photoresistor detects
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: GOSUB Back_Up ' shadow, back up & turn right. GOSUB Turn_Right ELSEIF (IN3 = 0) THEN ' Right photoresistor detects GOSUB Back_Up ' shadow, back up & turn left. GOSUB Turn_Left ELSE ' Neither photoresistor detects GOSUB Forward_Pulse ' shadow, apply a forward pulse. ENDIF E LOOP L ' -----[ Subroutines ]--------------------------------------------------------' Forward_Pulse: ' Send a single forward pulse. PULSOUT 12,650 PULSOUT 13,850 PAUSE 20 RETURN Turn_Left: ' Left turn, about 90-degrees. FOR pulseCount = 0 TO 20 PULSOUT 12, 650 PULSOUT 13, 650 PAUSE 20 NEXT RETURN Turn_Right: FOR pulseCount = 0 TO 20 ' Right turn, about 90-degrees. PULSOUT 12, 850 PULSOUT 13, 850 PAUSE 20 NEXT RETURN Back_Up: ' Back up. FOR pulseCount = 0 TO 40 PULSOUT 12, 850 PULSOUT 13, 650 PAUSE 20 NEXT 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

RoamingPhotoresistorDividers - GOSUB Back_Up ' shadow, back...

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