I've got a small LED garden lamp, battery operated, that turns on with a switch.

I am currently trying to use a photoresistor that I have to make it turn on when it gets dark (so I don't have to switch it on manually)

My first thought was to use a microcontroller like an attiny to do it but then I realized I might be able to achieve this with just a transistor (which I already have too)

The problem is that the transistor makes the light fade in and out as I'm using the photoresistor in a current divider configuration attached to the base of the transistor. When it gets dark, the photoresistor gets high impedance and current flows to the base of the NPN.

I would like to know if there's a way of making the transistor turn off and on "fully" without going through the active region.

I tried using a diode at the base of the NPN, hoping it would block everything until the voltage was high enough to go through and fully turn on the transistor but with no success... it still fades in and out.

Any ideas of something I can do with just these simple components?

Thanks in advance.



simulate this circuit – Schematic created using CircuitLab

Added the schematic of what I did initially.

I also tried a darlington pair but the results were similar.

  • 1
    \$\begingroup\$ Do you have any PNP transistors? You want some hysteresis, to make the switching be snap-action, and you want some amplification, so that you don't use much current when the circuit is idle. Frankly, if you want to hold to low battery drain this would be much easier with a modern micropower comparator (or that ATTiny) than with discrete transistors, but there may be a two or three transistor circuit that would come close to what you need. \$\endgroup\$
    – TimWescott
    Oct 21, 2018 at 20:55
  • \$\begingroup\$ Tell us the resistance of the sensor at the light level you want the lights to turn on, and how much current the light draws when it's on. \$\endgroup\$
    – TimWescott
    Oct 21, 2018 at 20:56
  • \$\begingroup\$ Not knowing circuit particulars I'm foregoing the hysteresis, but how about just doing a darlington configuration, that would get you a snappier ON/OFF response and it's relatively easy to try. \$\endgroup\$
    – user201365
    Oct 22, 2018 at 3:55
  • \$\begingroup\$ You may want look up "Schmitt trigger" you could build one with 2 NPNs \$\endgroup\$
    – sstobbe
    Oct 22, 2018 at 23:39
  • \$\begingroup\$ @Daniel - can you give us a part number for that photo resistor? Have you determined what resistance values correspond to "turn on" and "turn off"? \$\endgroup\$
    – user201365
    Oct 22, 2018 at 23:52

1 Answer 1


Something like this


simulate this circuit – Schematic created using CircuitLab


I added VDD label on the top-wire; thank you for noticing.

Notice I added R5 on the left. Without R5 demanding current to produce a Vbe (which varies with collector current and with temperature and with Beta), a reliable trip point (light level) will not occur.

This is better, and more like a standard comparator, thus easier for you to tweak in simulation.


simulate this circuit

  • \$\begingroup\$ I notice everybody uses the CircuitLab embeds, but with "topological" component values. Is this standard practice? Reason I ask is that it's hard for me to evaluate somebody's design if the .OP is something totally different. It's not meant as a criticism or anything, just wondering. \$\endgroup\$
    – user201365
    Oct 22, 2018 at 23:50
  • \$\begingroup\$ Since the LDR resistance is not given, picking the other resistors is a bit difficult. \$\endgroup\$ Oct 23, 2018 at 4:59
  • \$\begingroup\$ @analogsystemsrf - My bad, should have posted the schematic in the first place. The maximum resistance I can get is 600K when in the dark. Would this be the value I put in the schematic (like I did)? Or should I try to type both the minimum and maximum values? \$\endgroup\$ Oct 23, 2018 at 14:21
  • \$\begingroup\$ @analogsystemsrf - Thanks for the practical input. I'll definitely try it. However, I can't really understand where is the Voltage input in that circuit. I'm assuming I should connect my load to the leads on the top of R1 and Q1 but where do I plug in the juice? \$\endgroup\$ Oct 23, 2018 at 14:25
  • \$\begingroup\$ @ Daniel Nabais Thanks for your questions. I've provided a more precise comparator, as a new schematic. I think it will perform well from +5v to +9v. Do you need +3.3v? \$\endgroup\$ Oct 24, 2018 at 4:54

Your Answer

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

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