Page 222 · Robotics with the Boe-Bot
average = timeRight + timeLeft / 2
difference = average / 6
Now, the
variable can be used in this
difference
large value when the lighting is low, and a small value when the lighting is bright.
IF (timeLeft > timeRight + difference) THEN
PULSOUT 13, 850
PULSOUT 12, 850
ELSEIF (timeRight > timeLeft + difference) THEN ' Turn left.
PULSOUT 13, 650
PULSOUT 12, 650
ELSE
PULSOUT 13, 850
PULSOUT 12, 650
ENDIF
Example Program – RoamingTowardTheLight.bs2
Unlike RoamingWithPhotoresistorDividers.bs2 on page 201, this program will be very
responsive to your hand casting a shadow over the photoresistor, regardless of whether
the light is bright or dim. This program does not need to change resistors depending on
the lighting conditions. Instead, it takes into account the lighting conditions and the
sensitivity adjustment is made in software using the
For this program to work well, your photoresistors should respond similarly to similar
light levels. If the RC circuits are severely mismatched, your measurements from Table 6-1
will be very different under the same lighting conditions. You can correct these mismatched
measurements using techniques discussed in Appendix F: Balancing Photoresistors.
This program measures the overall average of
set the
between the
difference
to justify delivering a turning pulse.
√
Enter, save, and run RoamingTowardTheLight.bs2
√
Take it to various areas, and let it roam, and verify that you can change its course
by casting a shadow over one of the photoresistor RC circuits, regardless of the
lighting conditions.
IF...THEN
average
timeLeft
and
timeLeft
timeRight
statement, and it will be a
' Turn right.
' Go forward.
and
variables.
difference
and
and uses it to
timeRight
measurements that's needed
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?
Questions and answers