As part of my first proper Arduino project (a bed-side clock) I need the brightness of the LEDs to vary with the ambient light, so that when it is bright in the room the LEDs are bright, and they reduce in intensity in the dark. So, I thought a simple voltage divider would suffice (as opposed to any PWM or transistor-based solution). So, I have a circuit like this as my testbed:
Without knowing the exact characteristics of the LDR, I think the range will go from something like a few hundred Ohms in bright light to a few million in the dark. So, I expected that placing a 47 MO resistor in the voltage divider would supply plenty of voltage (>50% of Vin) to my test LED. However, in the dark the LED goes out, and I really don’t understand why.
This circuit is unlikely to work as you would like, but to characterize the LDR, use your multimeter to measure the LDR resistance as a function of light intensity.
If you don’t have a multimeter, now is the time to get one.
Many thanks for taking the time to reply, both of you. I was of course getting hung up on voltage without even considering current - newbie oversight :S
The LDR came as part of a kit, and there was no data sheet for it, nor any kind of part number. I have got a multimeter but the maximum range is 2 MO, and in darkness the LDR exceeeds that.
Now that I think about it, a variation of your idea might work. The problem is that the dark resistance is so high that the LED won’t light, but you can reduce the effect by putting another resistor in parallel with the LDR. Try the attached circuit, adjusting R1 so that the LED is just bright enough at night.
This would probably work a lot better as a constant current circuit. A single transistor with the LED at the collector and a current feedback resistor at the emitter using the LDR and a fixed resistor in a divider at the base. I can draw a diagram if I can’t find one online.
Just wanted to let people know that I have successfully gone down the resistors-in-parallel route and it is behaving exactly as I want. Currently using a 10K resistor which gives me about 13mA in daylight and 0.5mA in total darkness - but I am happy to play around with the 2nd resistor now I’ve got (R1xR2)/(R1+R2) firmly in my head I might use a variable resistor in version 2…