My goal is to reduce LEDs brightness dynamically with LDR. Power supply is 12V car battery. LEDs are about 3V. LDR will vary from 10k to 100k.

I found out that I can use LM317 to adjust voltage. Now I do not know how to decrease voltage even more when it's dark out side (LDR resistance increases). I cannot use LDR as resistor for adjustments, because it will increase voltage when there is little or no light. I need just opposite.

I found circuits that use Pulse Width Modulation to adjust voltage with LM317, so that gives me an idea, that I can use op-amp with LDR to achieve what I want? But I am not sure how to wire this circuit correctly then.

This circuit might be right direction Problems controlling an LM317 with an op-amp

  • \$\begingroup\$ Microcontroller based solution would be the easiest. Especially if you want variable brightness instead of on/off darkness detection. \$\endgroup\$ – Passerby Oct 20 '15 at 12:10
  • \$\begingroup\$ Can you share some ICs for this? \$\endgroup\$ – chba Oct 20 '15 at 12:21
  • \$\begingroup\$ Any common micro controller will do. Good starter ones are MSP430s or Arduinos. \$\endgroup\$ – Passerby Oct 20 '15 at 12:47

Find a micro-controller with A2D and PWM features - one of the PIC-12 series should do.

wire up the LDR in a voltage divider configuration to the A2D input

wire up the LED to the PWM output

Create a power supply for the micro, using the LM317 or similar to reduce the 12V to the PIC supply voltage (5V or 3.3V)

Write a program to read the LDR resistance as a voltage, and output an LED brightness as a PWM percentage

Program your micro, test and debug.


You could use 2 555 timers or a 556 to achieve variable duty cycle based on the photo-resistor. It really could be easier to use something like an Arduino, but if you are fine with an old fashioned analog solution, try something like this:

enter image description here

If you Google 555 PWM, you will find a lot of results on this topic. Essentially the VR1 in the schematic above would be replaced with your photo-resistor. Depending on the resistance range of your photo-resistor you may need to modify some of the supporting resistors and capacitors for the Monostable stage (Left IC Circuit).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.