![]() The figure below plots the logarithm of resistance versus the logarithm of the light intensity. It is interesting to look at a typical datasheet. Below are some refernces for the lux-to-resistance relationship. const double k = 5.0/1024 const double luxFactor = 500000 const double R2 = 10000 const double LowLightLimit = 200 const double B = 1.3*pow(10.0,7) const double m = -1.4 const int LED = 7 double light_intensity (int RawADC0) Of course you could also do something more useful, such as tell a relay to turn on a light. The LED is connected to pin 7 and to ground through a 230 Ohm resistor. In addition, and just for fun, an LED is turned on if the intensity falls below light_intensity. It computes the light intensity in lux from this value and sends it out once per second over the serial port. The Arduino reads the voltage at A0encoded as an integer between. The Codeīelow is the Arduino code which implements the above theory. Substitute the formula for the current in this expression and solve for R1 to obtain R1 = (5.0/V2 - 1)R2 (*) Another application of Ohm’s Law gives V2 = I x R2. On the right of the figure above, you see a derivation of the current I through the circuit. The computation is an exercise in Ohm’s law, V = IR We need to compute R1, which will give us the light intensity, in terms of V2. The voltage V1 is what the Arduino measures at A0. To the right of the circuit diagram, you see the voltage drops: V1 across R1, V2 across R2, and the total voltage drop Vtotal = V1 + V2. The two resistors are tied together and the tie point is attached to the analog input pin A0. In the figure below you see the circuit: a voltage divider with the LDR R1 attached the 5 volt pin of the Arduino and a 10,000 Ohm resistor R2 attached to the ground pin. (See the references at the end for more on the L versus R relationship). ![]() This is the required relation between light intensity and resistance of the LDR. The exponent m is negative, so that light intensity decreases as resistance increases. So that L = e^b R^m L = BR^m where B = e^b Then (using natural logarithms), we have log L = m(log R1) + b It will be a downward-sloping line with equation y = mx + b. Take a ruler and draw the line that best fits the data (the dots). Plot y = log L versus x = log R1 on some graph paper. ![]() Record L and R1 for various light levels. Expose both the meter and the LDR to the same light source. If you don’t have “real” light meter, you can get one for your smart phone. Get a light meter to measure L and an ohmmeter (e.g, multimeter) to measure R1. To use an LDR, one needs to know the coefficients B and m. The intensity L is measured in lux = lumens per square meter, while R1 is measured in Ohms. The equation on the right of the figure above gives an empirical formula for how L and R1 are related.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |