Light Dependent Resistors and Arduino
From Learning
Light dependent resistors (LDRs) or photoresistors are resistors that have high resistance in the dark and decrease in resistance as they are exposed to more light.
Contents |
Voltage Divider
The Arduino reads the voltage at a pin, so in order for the LDR to be read by the Arduino, it needs to affect the voltage. This is done by creating a voltage divider.
Voltage dividers are circuit made of 2 resistors. The resulting voltage is the ratio of those resistors.
By replacing one of the resistors with an LDR, you have made a variable voltage divider dependent on the light level.
Circuit
The below circuit has two LDRs each in a different position within the voltage divider. The resistor value that you choose will vary according to the range of the LDR and the light levels you want to detect. 10kOhms may be a good starting place.
Full Source
void setup() { // open the serial connection at // 9600 BAUD Serial.begin(9600); } void loop() { // store the value read from pins 1 and 2 // into a variable int sensorValue1 = analogRead(1); int sensorValue2 = analogRead(2); // print that variable over the serial connection Serial.print(sensorValue1); Serial.print(' '); Serial.println(sensorValue2); }
See Also
- This page was last modified on 7 March 2012, at 15:56.
- This page has been accessed 3,902 times.







Content available under Attribution-NonCommercial-ShareAlike 3.0 Unported.