RoamingTowardTheLight

RoamingTowardTheLight - T HIGH 6 ' Left RC time...

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 - RoamingTowardTheLight.bs2 ' Boe-Bot roams, and turns away from dark areas in favor of brighter areas. ' ' {$Stamp bs2} ' Stamp directive. ' {$PBASIC 2.5} ' PBASIC directive. ' ' -----[ Variables ]---------------------------------------------------------- ' ' Declare variables for storing measured RC times of the ' timeLeft VAR Word timeRight VAR Word average VAR Word difference VAR Word d ' -----[ Initialization ]----------------------------------------------------- ' FREQOUT 4, 2000, 3000 F ' -----[ Main Routine ]------------------------------------------------------- ' DO D GOSUB Test_Photoresistors GOSUB Average_And_Difference GOSUB Navigate LOOP L ' -----[ Subroutine - Test_Photoresistors ]----------------------------------- ' Test_Photoresistors:
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: 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 - Average_And_Difference ]--------------------------------' Average_And_Difference: A average = timeRight + timeLeft / 2 difference = average / 6 RETURN ' -----[ Subroutine - Navigate ]----------------------------------------------' Navigate: N ' Shadow significantly stronger on left detector, turn right. IF (timeLeft > timeRight + difference) THEN PULSOUT 13, 850 PULSOUT 12, 850 ' Shadow significantly stronger on right detector, turn left. ELSEIF (timeRight > timeLeft + difference) THEN PULSOUT 13, 650 PULSOUT 12, 650 ' Shadows in same neighborhood of intensity on both detectors. ELSE PULSOUT 13, 850 PULSOUT 12, 650 ENDIF PAUSE 10 RETURN...
View Full Document

Page1 / 2

RoamingTowardTheLight - T HIGH 6 ' Left RC time...

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