Page 202 · Robotics with the Boe-Bot
ELSE ' Neither photoresistor detects
GOSUB Forward_Pulse ' shadow, apply a forward pulse.
ENDIF
LOOP
' -----[ 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
Your Turn – Improving performance
You can improve your Boe-Bot’s performance by commenting some of the subroutine
calls that were designed to help the Boe-Bot back away from obstacles and then turn to
avoid them. Figure 6-6 shows an example where the two
Turn_Left subroutine calls are
commented from the
IF…THEN statement when the condition is that both photoresistors
detect a shadow. Then, when only individual photoresistors detect shadows, the
Back_Up
subroutine calls are commented so that the Boe-Bot only turns in response to a shadow.