I'm trying to make an LED dim according to the ambient light (darker ambient -> brighter LED), through use of an LDR.

I'm using a voltage divider with an NPN transistor (BUL38D). I've tried multiple values for each of the resistors shown, but always seem to end up with a fairly narrow range of light intensity from the LED.

It's either bright or dim, but changes in the LDR (turning the lights off or putting my finger over it) don't seem to change the LED's brightness much, although some change is visible. When I shine my lamp directly at the LDR the LED does turn off.

Is there anything I'm doing wrong? I'm trying to get 20 mA when totally dark (here the LDR is about 400 kΩ) and transistor turned off at LDR = 8 kΩ or so. Do I need a higher voltage?

Updated circuit

Edit: I tried the Darlington pair without the rheostat but with a 30 kΩ resistor instead, and after some tweaks it ended up with the sensitivity range I wanted, circuit below. I appreciate all your replies, I learned a lot!

In order to add more LEDs, how should it be done in such a way that they all keep their brightness up?

enter image description here

  • 1
    \$\begingroup\$ A very warm welcome to the site. Please can you add your LDR part number onto your schematic, along with putting the BJT part number on it. Thanks. \$\endgroup\$
    – TonyM
    Aug 12, 2022 at 22:03
  • \$\begingroup\$ Guilherme, you will need to work out the details before you go forward into a design. Go to this link and look at the table they provide for luminance in lux (flux per unit area.) Decide what you want for current in your LED for various important points (as you decide they are.) If you need to, grab your LED and feed it from a current source to get those numbers. Once you have a table of lux to LED current for us, then we can help out in selecting an LDR (or other means) and in providing a circuit of some kind. Otherwise, not so much. \$\endgroup\$
    – jonk
    Aug 13, 2022 at 6:02
  • \$\begingroup\$ Using a nonlinear element (LDR) to control a linear element (LED) is tricky. Why not use a photodiode and a simple current amplifier? \$\endgroup\$
    – John Doty
    Aug 13, 2022 at 14:03
  • \$\begingroup\$ @JohnDoty that sounds interesting. Should I just place the LED and resistor in the emitter and place the PD in the base with no voltage divider? \$\endgroup\$ Aug 13, 2022 at 14:20
  • \$\begingroup\$ You should start from a quantitative calculation: how bright do you want the LED to be for a given level of ambient light? \$\endgroup\$
    – John Doty
    Aug 13, 2022 at 14:23

3 Answers 3


You can try replacing the 30K resistor with a 500K rheostat with 10K in series, and adding a second transistor to make a Darlington pair.


simulate this circuit – Schematic created using CircuitLab

  • 1
    \$\begingroup\$ Its never robust to control base current in a BJT with a base R (R3); even worse with a Darlington. \$\endgroup\$
    – jp314
    Aug 13, 2022 at 1:36
  • \$\begingroup\$ @jp314 R3 isn't even necessary. The voltage divider is the thing. I just left it in there for safety in case OP wires it up wrong. \$\endgroup\$ Aug 13, 2022 at 1:58
  • \$\begingroup\$ Thanks for the tip, will get myself a rheostat. To be clear, assuming R2+R1= 30k ohm, the LDR would have to be around 20k ohm for the transistors to turn on right? If Vbeon is around 1V, Vb1 has to be 2V. And from that, the rheostate controls this LDR limit \$\endgroup\$ Aug 13, 2022 at 7:28
  • 1
    \$\begingroup\$ Vbe of a Darlington pair is around 1.2V so it will switch around 10K. If you want it to dim more smoothly, connect the emitter to the diode+resistor and collector to +5. \$\endgroup\$ Aug 13, 2022 at 7:56

If you move the LED and the 100 ohm resistor to the emitter path and connect the collector directly to 5V, you remove the voltage gain of the transistor and use only the current gain.

This uses a bigger part of the voltage divider range of 30 kohm and the LDR. You can try other resistor values than 30 kohm to get a better conversion of the LDR resistance.

However the LDR is not a linear sensor in this circuit, solutions with more components (OpAmps) can improve this.

  • \$\begingroup\$ This worked! In the sense it's now clear the LED turns on when the room is dark and turns off when the room is bright. The LED brightness at its maximum is decent, although I would like more if possible. Maybe the Darlington transistor Spehro suggested does the trick. Thank you so much \$\endgroup\$ Aug 13, 2022 at 5:47
  • \$\begingroup\$ @GuilhermeGaspar The BUL38D is a monster with very low current gain, not the optimal transistor in this circuit. Use a much smaller one like BC547B or 2N3904. \$\endgroup\$
    – Jens
    Aug 13, 2022 at 17:56

Generally, you want low gain in this circuit; you also want plan what you need the circuit to do.

The LDR conductivity (1/R) is approximately proportional to the incident light. Human perception of 'light' and 'dark' may span many decades -- do you want the LED to work over that range ?

Do you want the total illumination to be constant ? If so, then the sum of LED + incident = constant; the LDR would then have a constant resistance, so your circuit would drive the LED to the point where R(CDS) is constant. If so, then try take Spehro's circuit; remove R3 and R4; place ~ 100 Ω in the emitter of Q2 (may not be necessary). R2 might be better at 100 kΩ. Arrange your hardware so that the LDR is illuminated equally by the LED and ambient light (or use a 2nd LED in series for just that portion).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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