![Parallax Boe-Bot Student Manual Download Page 227](http://html2.mh-extra.com/html/parallax/boe-bot/boe-bot_student-manual_3646721227.webp)
Chapter 6: Light Sensitive Navigation with Photoresistors
· Page 213
PAUSE 3
RCTIME 6,1,timeLeft
HIGH 3 ' Right RC time measurement.
PAUSE 3
RCTIME 3,1,timeRight
DEBUG CRSRXY, 0, 3, ' Display measurements.
DEC5 timeLeft,
" ",
DEC5 timeRight
PAUSE 100
LOOP
Your Turn
√
Try facing the Boe-Bot in different directions, and repeat your measurements.
√
For better results, you can average your measurements for "flashlight on" and
"flashlight off" and replace the values in Table 6-1 with your average values.
Following the Flashlight Beam
You have been using variable declarations up to this point. For example,
counter VAR
Nib
gives the name
counter
to a particular memory location in the BASIC Stamp’s
RAM. After you have declared the variable, every time you use
counter
in a PBASIC
program, it uses the value stored at that particular location in the BASIC Stamp’s RAM.
You can also declare constants. In other words, if you have a number you plan on using
in your program, give it a useful name. Instead of the
VAR
directive, use the
CON
directive. Here are some
CON
directives from the next example program:
LeftAmbient CON 108
RightAmbient CON 114
LeftBright CON 20
RightBright CON 22
Now, everywhere in the program the name
LeftAmbient
is used, the BASIC Stamp will
use the number 108. Everywhere
RightAmbient
is used, the BASIC Stamp will use the
value 114. Likewise, everywhere
LeftBright
appears, it’s really the value 20, and
RightBright
is 22. You will substitute your values from Table 6-1 before running the
program.