Chapter 6: Light Sensitive Navigation with Photoresistors
· Page 231
E2.
a) Vo = 1.4 V
R = (5 * (2000/Vo)) – 2000
= (5 * (2000/1.4)) – 2000
= (5 * 1428.57) – 2000
= 7142.86 – 2000
= 5142.86
= 5143 Ohm
When Vo = 1.4V, R = 5143
Ω
b) Vo = 1.0 V
R = (5 * (2000/1)) – 2000
= (5 * 2000) – 2000
= (10000) – 2000
= 8000
= 8 kOhm
When Vo = 1.4V, R = 8 k
Ω
c) Vo = 3.0 V
R = (5 * (2000/3.0)) – 2000
= (5 * 666.67) – 2000
= 3333.33 – 2000
= 1333.33
= 1333 Ohm
When Vo = 1.4V, R = 1333
Ω
E3.
The average of these three values in a variable named
myAverage
, storing 7/8 in
myScaledAvereage
:
myAverage = firs secon thirdValue / 3
myScaledAverage = myAverage * 7 / 8
Declarations as separate variables:
myAverage VAR Word
myScaledAverage VAR Word
Declarations using aliasing:
myAverage VAR Word
myScaledAverage VAR myAverage
P1.
The first step is to use "TestBothPhotoresistors.bs2" and determine the values for
the white surface and the black paper. Similar to
"FlashlightControlledBoeBot.bs2", these values can be coded as constants.
Then,
IF…THEN
statements can be used to determine whether the values are
above or below the average readings. (For the author's Boe-Bot, scaling was not
necessary). Here's a program solution that makes the Boe-Bot recognize the
difference between black and white surfaces.