A common and easy-to-use device for measuring light intensity is the light-dependent resistor or LDR. They are also sometimes called photoresistors. The brighter the light falling on the surface of the LDR, the lower the resistance. A typical LDR will have a dark resistance of up to 2M and a resistance when illuminated in bright daylight of perhaps 20K. We can convert this change in resistance to a change in voltage by using the LDR, with a fixed resistor as a voltage divider, connected to one of our analog inputs.
Using LDR to measuring light |
With a fixed resistor of 100K, we can do some rough calculations about the voltage range to expect at the analog input. In darkness, the LDR will have a resistance of 2M, so with a fixed resistor of 100K, there will be about a 20:1 ratio of voltage, with most of that voltage across the LDR, so that would mean about 4V across the LDR and 1V at the analog pin. On the other hand, if the LDR is in bright light, its resistance might fall to 20K . The ratio of voltages would then be about 4:1 in favor of the fixed resistor, giving a voltage at the analog input of about 4V. A more sensitive photo detector is the phototransistor. This functions like an ordinary transistor except there is not usually a base connection. Instead, the collector current is controlled by the amount of light falling on the phototransistor.