RoamingWithWhiskers

RoamingWithWhiskers - ELSEIF (IN7 = 0) THEN ' Right whisker...

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

View Full Document Right Arrow Icon
' Robotics with the Boe-Bot - RoamingWithWhiskers.bs2 ' Boe-Bot uses whiskers to detect objects, and navigates around them. ' ' {$STAMP BS2} ' Stamp directive. ' {$PBASIC 2.5} ' PBASIC directive. ' ' -----[ Variables ]---------------------------------------------------------- ' pulseCount VAR Byte ' FOR. ..NEXT loop counter. p ' -----[ Initialization ]----------------------------------------------------- ' FREQOUT 4, 2000, 3000 ' Signal program start/reset. F ' -----[ Main Routine ]------------------------------------------------------- ' DO IF (IN5 = 0) AND (IN7 = 0) THEN ' Both whiskers detect obstacle GOSUB Back_Up GOSUB Turn_Left GOSUB Turn_Left ELSEIF (IN5 = 0) THEN ' Left whisker contacts GOSUB Back_Up GOSUB Turn_Right
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: ELSEIF (IN7 = 0) THEN ' Right whisker contacts GOSUB Back_Up ' Back up & turn left GOSUB Turn_Left ELSE ' Both whiskers 1, no contacts GOSUB Forward_Pulse ' Apply a forward pulse ENDIF ' and check again LOOP L ' -----[ Subroutines ]--------------------------------------------------------' Forward_Pulse: ' Send a single forward pulse. PULSOUT 13,850 PULSOUT 12,650 PAUSE 20 RETURN Turn_Left: ' Left turn, about 90-degrees. FOR pulseCount = 0 TO 20 PULSOUT 13, 650 PULSOUT 12, 650 PAUSE 20 NEXT RETURN Turn_Right: FOR pulseCount = 0 TO 20 ' Right turn, about 90-degrees. PULSOUT 13, 850 PULSOUT 12, 850 PAUSE 20 NEXT RETURN Back_Up: ' Back up. FOR pulseCount = 0 TO 40 PULSOUT 13, 650 PULSOUT 12, 850 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

RoamingWithWhiskers - ELSEIF (IN7 = 0) THEN ' Right whisker...

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