Trying to develop a dark sensor. Have successfully made it but with a major problem. As you can see the circuit here:

dark sensor relay

When the LDR is covered the LED lights up using the relay NO terminal. However the problem is that with slight disturbance of light falling on the LDR the relay triggers on and off very quickly and that makes the LED blink rapidly.

I want to slow down the switching speed. ie, the relay coil only turns off if the LDR is illuminated for atleast a second or so.

Note that I need a high current to run the LED in high brightness. I need around 450-500mA current through it. That is the reason I have used a relay.

  • 2
    \$\begingroup\$ Try to add a resistor 1M or lower (910k, 820k or 680k) between the collector of a second BJT and the base of the first BJT. \$\endgroup\$
    – G36
    Apr 17, 2017 at 17:49
  • \$\begingroup\$ @G36 you may want to point out that is adding hysteresis. \$\endgroup\$
    – Trevor_G
    Apr 17, 2017 at 17:54
  • \$\begingroup\$ It's probably a good idea to add a little capacitance across R1 or better add a small base resistor on Q1 and capacitor to ground with a long time constant to filter out natural light variations. \$\endgroup\$
    – Trevor_G
    Apr 17, 2017 at 17:55
  • \$\begingroup\$ ... you need something that has a little hysteresis... link \$\endgroup\$
    – AltAir
    Apr 17, 2017 at 19:01
  • \$\begingroup\$ Possible duplicate of Basic circuit to keep LED either on or off depending on night/day \$\endgroup\$ Jul 14, 2017 at 10:45

2 Answers 2


Here's a circuit that should give you a few seconds' time-delay (you can adjust the time-delay by changing the value{s} of R2 &/or C1), some hysteresis to reduce cyclic switching, and should consume a little less power, due to the use of a comparator & a mosfet, instead of the 3 BJTs.


simulate this circuit – Schematic created using CircuitLab

NOTE: As @Trevor pointed out on laptop2d's answer, you could remove the relay & freewheel diode, then simply ground the LEDs through the MOSFET (same as how the relay is grounded through it now) to switch them.

  • \$\begingroup\$ This looks promising. I will get the comparator and try it. \$\endgroup\$
    – soul6002
    Apr 18, 2017 at 8:01
  • \$\begingroup\$ There are several problems with this answer: no hysteresis, the LM393 has an open-collector output, there are only two transistors in the OP's circuit. \$\endgroup\$
    – Dave Tweed
    Jul 16, 2017 at 11:12

The concept you are missing is called hysteresis. This has been discussed here many times before. Some very similar circuits to what you want are discussed at:


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.