Parallax Boe-Bot Student Manual page 286

Hide thumbs Also See for Boe-Bot:
Table of Contents

Advertisement

Page 272 · Robotics with the Boe-Bot
FREQOUT 8,1, irFrequency
irDetect = IN9
' Commands not shown...
NEXT
The first time through the
places the value 37500 in the
37500 after the
LOOKUP
LED connected to P8. As in the previous chapter, the value of
variable.
The second time through the
irDetect
is now 1, which means the
freqSelect
variable, and the process is repeated for this higher frequency. The third
irFrequency
time through, it's repeated again with 39500, and so on. The result is remarkable,
especially considering you are using parts that were designed for a completely different
purpose, to make IR communication between a handheld remote and a television
possible.
Example Program – TestLeftFrequencySweep.bs2
TestLeftFrequencySweep.bs2 does two things. First, it tests the left IR LED/detector pair
(connected to P8 and P9) to make sure they are functioning properly for distance
detection. However, it also demonstrates how the frequency sweep illustrated in Figure
8-2 is accomplished.
When you run the program, the Debug Terminal will display your zone measurement.
There are many possible yes-no patterns that can be generated; two are shown in Figure
8-3. The test patterns will vary depending on the characteristics of the filter inside the IR
detector.
The program determines which zone the detected object is in by counting the number of
"No" occurrences. Notice that even though the two Debug Terminal test patterns in
Figure 8-3 are different,
Therefore, "Zone 2" is the location of the object detected in both examples.
...
loop,
FOR
NEXT
freqSelect
variable. Since
irFrequency
command, the
FREQOUT
LOOKUP
they both have three "Yes" and two "No" occurrences.
is 0, so the
LOOKUP
irFrequency
command sends that frequency to the IR
is then saved in the
IN9
...
loop, the value of
FOR
NEXT
command places 38250 into the
command
contains

Advertisement

Table of Contents
loading

Table of Contents