Page 200 · Robotics with the Boe-Bot
ACTIVITY #2: ROAM AND AVOID SHADOWS LIKE OBJECTS
Since the photoresistor dividers behave similarly to whiskers, it's worth examining
what's involved in adapting RoamingWithWhiskers.bs2 so that it functions with the
photoresistor dividers.
Adapting RoamingWithWhiskers.bs2 for the Photoresistor Dividers
All you really have to do is adjust the
, instead of
and
IN3
IN7
Figure 6-5: Modify RoamingWithWhiskers.bs2 for Use with Photoresistor Dividers
' From RoamingWithWhiskers.bs2
IF (IN5
= 0) AND (IN7 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
ELSEIF (IN5
= 0) THEN
GOSUB Back_Up
GOSUB Turn_Right
ELSEIF (IN7
= 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
ELSE
GOSUB Forward_Pulse
ENDIF
Example Program – RoamingWithPhotoresistorDividers.bs2
√
Open the program RoamingWithWhiskers.bs2 from page 179, and save it as
RoamingWithPhotoresistorDividers.bs2.
√
Make the modifications shown in Figure 6-5.
√
Reconnect power to your board and servos.
√
Run and test the program.
IF...THEN
. Figure 6-5 demonstrates how to make these changes.
IN5
' Modified for
' RoamingWithPhotoresistor
' Dividers.bs2
IF (IN6
ELSEIF (IN6
ELSEIF (IN3
ELSE
ENDIF
statements so that they monitor
= 0) AND (IN3 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
= 0) THEN
GOSUB Back_Up
GOSUB Turn_Right
= 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Forward_Pulse
and
IN6
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers