|Romantic lighting sensor|
I had some LDRs on stock which had values of about 1 kOhm at 100 lux and about 8 kOhm at 10 lux (the darker the more resistance). This was almost equal to the LDRs recommended in the books parts list (page 94) so I could also use the 20kOhm resistor. Could I?
|added lines of code to print the values|
In my example this meant (I added some lines of code to get the results in the serial monitor):
|~ 100 lux|
~ 100 lux: analogValue of 97 (0.11 volts)
~ 10 lux: analogValue of 611 (0.71 volts)
In the experiment the LDR is connected to ground and the fixed resistor to Vcc. If I calculate the formula:
Vout = (R2 (LDR)/ R1 (fixed resistor) * R2 (LDR)) * Vin
|~ 10 lux|
I get (at ~ 100 lux, LDR resistance ~ 1 kOhm, fixed resistor = 20 kOhm):
Vout = (1 kOhm/ 20 kOhm + 1 kOhm) * 3.3 volts
Vout = 0.157 volts
for ~ 10 lux (LDR resistance ~ 8 kOhm):
Vout = (8 kOhm / 20 kOhm + 8 kOhm) * 3.3 volts
Vout = 0.94 volts
The calculated values show the same trend I found in the practical excercise.
|LDR covered to lower the brightness|
I'm kind of stuck now with this experiment. Do I have an error in reasoning or should the code tell exactly the inverse: analogValue low = too bright, analogValue high = too dark)?
Anyone to the rescue?