Casting shadows over both photoresistors at the same time can be difficult. When the
Boe-Bot is going forward, it is checking the photoresistors around 40 times/second. You will
have to move quickly to cast a shadow over both photoresistors between pulses. It helps to
move your hand rapidly from no shade to full shade to trigger both photoresistors at once.
Alternately, just leave your hand casting shade over both photoresistors while it executes a
maneuver. When it returns from the maneuver and checks the photoresistors again, it
should recognize that both photoresistors are in shade.
√
Verify that the Boe-Bot avoids shadows by using your hand to cast a shadow
over the photoresistors. Try no shadow, a shadow over the right photoresistor
divider (circuit connected to P3), a shadow over the left photoresistor divider
(circuit connected to P7), and a shadow over both photoresistor dividers.
√
Update the comments such as the title and descriptions of reactions to whisker
presses to reflect the photoresistor circuit behavior. It should resemble the
program below when you are done.
' -----[ Title ]--------------------------------------------------------------
' Robotics with the Boe-Bot - RoamingWithPhotoresistorDividers.bs2
' Boe-Bot detects shadows photoresistors voltage divider circuit and turns
' away from them.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
' -----[ Variables ]----------------------------------------------------------
pulseCount
VAR
' -----[ Initialization ]-----------------------------------------------------
FREQOUT 4, 2000, 3000
' -----[ Main Routine ]-------------------------------------------------------
DO
IF (IN6
= 0) AND (IN3 = 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
GOSUB Turn_Left
ELSEIF (IN6
= 0) THEN
GOSUB Back_Up
GOSUB Turn_Right
ELSEIF (IN3
= 0) THEN
GOSUB Back_Up
GOSUB Turn_Left
Chapter 6: Light Sensitive Navigation with Photoresistors · Page 201
Byte
' Stamp directive.
' PBASIC directive.
' FOR...NEXT loop counter.
' Start/restart signal.
' Both photoresistors detects
' shadow, back up & U-turn
' (left twice).
' Left photoresistor detects
' shadow, back up & turn right.
' Right photoresistor detects
' shadow, back up & turn left.
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers