I have a small light bulb (3W LED, E27/110V) that I am controlling using based on ambient brightness (it comes on when it is dark, and goes off when it is light). The circuit uses a BT136 triac, a MOC3041 optoisolator, and an IR phototransistor (I don't have a part number for it - 2 pins, black cap, looks like an LED).


simulate this circuit – Schematic created using CircuitLab

As built, it mostly works - it comes on when it is supposed to, and goes off when it is supposed to. D2 is included just as an indicator LED, SW1 is included so that the light can be turned on manually (bypassing the light activated circuit) if needed.

However, I have one issue with it:

The circuit is currently located fairly close to the light (around 1.5m under it - but the light faces upwards). When it gets dark enough, the light turns on and the light it produces turns off the phototransistor causing the light to flash. The light continues flashing for around 5 minutes (at varying frequencies), before it remains on. This implies that it doesn't take much additional darkness to offset the added light from the LED bulb. I chose the value for R1 that would let the light turn on at the appropriate time, and R2 is currently set around 50kohm (altering R2, changes the on time, but doesn't appear to help the flicker).

My indicator LED (D1), transitions to on when current through Q1 drops below 1.6uA to 1.3uA. (I am not confident enough in my meters to fully trust that number, but hopefully it provides an idea of the magnitude). In full direct sunlight the current through Q1 is up to 40mA.

Ideally, I would like to resolve this as simply as possible (e.g. with a minimum of ICs), however, my knowledge of electronic circuit design isn't yet where I want it to be in order to know the best course of action from here.

  • I could resolve this with a microcontroller fairly easily, but this seems like an inelegant solution.
  • I have considered implementing a circuit similar to one used to debounce a switch, but the time scale on those is normally on the order of milliseconds - whereas I need something over several minutes.
  • I have seen some designs which use two phototransistors pointed in different directions but would like to have a design where positioning isn't critical.
  • I have considered a soft-latching design, but am unsure how exactly to implement this. I was hoping for something which slightly changes the required input current once the light turns on - so that the added current flowing through the phototransistor when the light comes on, isn't enough to turn it off. I believe this would entail a feedback resistor, but unfortunately, am not sure how to implement this.

What would be the best way to resolve the flicker that occurs at dusk when the light turns on?

  • \$\begingroup\$ Basically you want the light sensor to trigger a monostable with a long (10 minute) period. That monostable then triggers a latch to turn the light on or off. 555 anyone? \$\endgroup\$
    – Majenko
    Jul 2, 2014 at 23:12
  • \$\begingroup\$ Does there exist any off-the-shelf product which does what you need with zero engineering cost? Try a Google search for [ "3 watt" LED night light ]. \$\endgroup\$ Feb 19, 2015 at 19:04

3 Answers 3


You need to introduce some hysteresis (positive feedback) into the circuit.

This is done, below, by connecting the collector of Q2 to the base of Q1 through the network R1 R2 R3. You'll probably have to fiddle with the resistor values in order to make it work with your phototransistor.

I simulated it with LTspice, and if you want to play with it, the circuit list is here.

enter image description here


U1 is an opamp functioning as a comparator with PT1 and R1 used to set the voltage on U1- to half of the supply when PT1 is illuminated enough to make its resistance equal to 1.2 megohms. R3 R4 and R5 are used to set PT1's low illumination trip level, with R3 and R5 limiting R4's range from about 2 to 3 volts, and R7 is used to provide hysteresis around the comparator and set the low and high switch points for the illumination incident on PT1.

The circuit has been simulated, appears to work nicely, and the LTspice circuit list is here.

enter image description here

  • \$\begingroup\$ Oops... The phototransistor shouldn't be labeled "Q1". I'll fix it in a while. \$\endgroup\$
    – EM Fields
    Jul 3, 2014 at 0:44
  • \$\begingroup\$ Thanks for the diagram - simple and elegant. Tried it out and it does work fairly well. It exhibits hysteresis, but it transitions to off when there is >20uA through PT1 (and I am looking for a transition at 2uA). I wasn't able to find the right combination of resistors for the desired transition (I'll try again at some point, now that I am gaining a better understanding of how the circuit works). It appears to work, however, by adding another NPN resistor feeding into Q1 (a Darlington pair?). More significantly though, I really want to thank you for introducing me to LTSpice. \$\endgroup\$
    – cyberx86
    Jul 5, 2014 at 5:24
  • \$\begingroup\$ I just finished designing almost the same circuit (my first real attempt a design from scratch). Firstly, thank you it is reassuring to know that what I was doing isn't way off. Secondly, a few questions: a) Are the reasons for using a MOSFET as Q1 (instead of a BJT) better switching ability and ability to sink more current (and possibly voltage driven instead of current driven)? b) What is the purpose of R2 and R6 c) Is the purpose of R8 as a pull-up resistor on the MOSFET gate? \$\endgroup\$
    – cyberx86
    Jul 6, 2014 at 4:48
  • \$\begingroup\$ I notice that you have R1 attached to the emitter of PT1 and the voltage feeding into the inverted input of U1, while I had R1 connected to the collector of PT1 and the voltage going into the non-inverting input. Is this to avoid the feedback from R7 affecting the input voltage? b) The other difference I see is that I set my thresholds on U1 in the 1 to 1.5V range (and chose R1 to give my transition in that range), while you chose the middle of the voltage range. See your approach, the middle of the voltage range seems much more logical. \$\endgroup\$
    – cyberx86
    Jul 6, 2014 at 5:20
  • \$\begingroup\$ One other question - you used a 75ohm resistor for R10 (which, given a Vf =1.25V, yields a current of (5-1.25)/75 = 50mA). The trigger current is 15mA. I understand that something a bit higher than 15mA provides an assurance that the signal will be transferred, but is there a specific reason for such a high current (instead of, say 20mA)? \$\endgroup\$
    – cyberx86
    Jul 6, 2014 at 5:36

You want hysteresis. Hysteresis is the same thing that keeps your thermostat from switching on and off every few seconds when the ambient temperature is very near the setpoint. Hysteresis can be implemented many ways.

You could introduce a delay after a state change. That is, when you change states, inhibit further changes for some time. This will at least limit the rate of the flashing. You might implement this with a microcontroller or some sort of discrete logic and a timer like the 555.

Alternately, you can introduce a degree of positive feedback such that the threshold brightness depends on if the light is currently on or off. For example, say the light is currently off, and the sensed brightness must go below "10" (some arbitrary unit) to trigger the light to turn on. When the light is on, the brightness must now increase to "15" before the light goes back off. So perhaps the brightness decreased to 10, the light turned on, and now the sensed brightness is 12, but this is less than the new threshold of 15. The Schmitt trigger is a kind of comparator with hysteresis.

  • \$\begingroup\$ Thank you - you made me do a bit of research, and learn something new - and put me on the right track. I guess I knew the basic concept to some degree, but not the name. I have managed to make the circuit work fairly well with a Schmitt trigger, but would like to simplify it a bit more (I seem to have doubled the number of components). (I actually had a Schmitt trigger circuit I had setup for my 'debounce' idea, but never followed through with it). \$\endgroup\$
    – cyberx86
    Jul 3, 2014 at 6:56

Place a resistor from D2 anode to base of Q2. Without knowing the specifications of your photo sensor (Q1), I cannot say what value of resistor. Perhaps 100K to 3 M-ohm. This will be positive feedback, which gives you the Hysteresis as mentioned by Phil Frost.

Alternatively you could place the resistor from collector of Q3 to base of Q2.

  • \$\begingroup\$ If I understand correctly, I want to implement positive feedback, where the output signal (e.g. D2 anode) reinforces the input. In the circuit, a current through the base-emitter junction of Q2, turns off Q3 (base to ground), so I would expect that a resistor from D2 to the base of Q2 would prevent the circuit from turning on (and when I add one, I am unable to get the circuit to turn on, even when I remove Q1 entirely). If I add a resistor between D1 and the base of Q3 however, the circuit appears to work better, but I haven't been able to prove that it adds hysteresis. \$\endgroup\$
    – cyberx86
    Jul 3, 2014 at 0:43
  • \$\begingroup\$ I don't see a D1 in the circuit, however, for understanding your Q2 collector could provide negative feedback (inverted signal ), and the collector Q3 (double inverted) can provide positive feedback. \$\endgroup\$
    – Marla
    Jul 3, 2014 at 0:52
  • \$\begingroup\$ forgot to mention that positive feedback is required for Hysteresis \$\endgroup\$
    – Marla
    Jul 3, 2014 at 0:58
  • \$\begingroup\$ Sorry - I meant D2. So, for positive feedback, I want something to the base of Q3 (and I think I can only get that from D2). At the moment, I have tried resistors between 50k and 10M between D2 and the base of Q3, this definitely increases the sensitivity of the circuit (turns on with higher levels of ambient light) but it still flickers as it turns on. \$\endgroup\$
    – cyberx86
    Jul 3, 2014 at 1:16
  • \$\begingroup\$ the only positive feedback in your existing circuit is from collector of Q3 to base of Q2. \$\endgroup\$
    – Marla
    Jul 3, 2014 at 1:34

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.