Page 296 · Robotics with the Boe-Bot
Questions
Q1. The relative sensitivity at 35 kHz is 30%. For 36 kHz, it's 50%
Q2. When
index = 4, prime = 11
index = 0, prime = 2
index = 1, prime = 3
index = 2, prime = 5
index = 7, prime = 19
Q3. Expressions are evaluated left to right. To override, use parentheses to change
the order.
Q4. Use the
CON directive.
BoilingPoint CON 100
E1. Frequency (kHz): 34 35 36 37 38 39 40 41 42
Sensitivity : 14% 30% 50% 76% 100% 80% 55% 35% 16%
E2. To solve this problem, put only four frequencies in the
LOOKUP list, and decrease
the
FOR…NEXT index by one.
FOR freqSelect = 0 TO 3
LOOKUP freqSelect, [37500, 38750, 39500, 40500],
irFrequency
FREQOUT 8, 1, irFrequency
irDetect = IN9
… commands not shown
NEXT
E3. • Sniff for IR interference with "IrInterferenceSniffer.bs2".
• Run Display BothDistances.bs2.
• White readings should be 0-1 in both sensors.
• Black readings should be 4-5 in both sensors.
• Straddle the line, both sensors should read 0-1.
• Move Boe-Bot back and forth over line, sensor over black line should read 4-5.
P1. In the solution below, the
Check_For_Intersection subroutine implements
the algorithm outlined. The left servo was arbitrarily chosen for counting the
forward pulses. A bit-sized variable named
isStuck is used as a flag to let the
Main program know whether an intersection has been reached. In the
Navigate_Intersection subroutine, the Boe-Bot goes forward past the
intersection and then backs up, checking the sensors, using
DO…LOOP…UNTIL.
Then it makes a preprogrammed 90 degree turn in the correct direction. If the