I'm looking a way to improve a lighting solution. The idea : to use a basic electrical switch already present in my room wall (with Line switched by the toggle switch + Neutral not switched) to control two lamp sources : one with low Lux and a given tint, a second one with high Lux and another tint.

Use case : when I firstly toggle the switch from Off to On : I want that the first lamp lights up. When I quickly toggle the switch from Off to On both times : I want that the two lamps light up.

In another word : I want to design a circuit to detect two rising front. I think about microcontroller circuit, or a basic flip/flop or shift register design. But I wonder if someone as an idea ?

I guess such circuit already exists, because some light bulb includes that feature (with n on/off cycle to control the light intensity), but I can't find solution or idea.

Thanks for your support.

  • \$\begingroup\$ Look at some Arduino board and some 220VAC Arduino switch boards. You could do it with flipflop but it's way more interesting and useful to learn how to use an MCU \$\endgroup\$
    – Damien
    Commented Jan 19, 2021 at 10:44
  • \$\begingroup\$ @Damien : thank you. Yes I perfectly know MCU universe :) I want to find a more "ligth" solution if possible. Because, at first switch ON, the MCU is not powered. And I aim to find a solution very small to integrate it inside the roof light on the room. \$\endgroup\$ Commented Jan 19, 2021 at 10:50
  • \$\begingroup\$ It will be difficult to do something small because you will need a power supply in any case to power the electronics. You will need to store the states in non-volatile memory or use some capacitor charge/discharge rate to define when the switch was pressed last time. \$\endgroup\$
    – Damien
    Commented Jan 19, 2021 at 11:05
  • \$\begingroup\$ Much easier to use a smart bulb and control it with your phone or voice via Alexa etc. \$\endgroup\$
    – Finbarr
    Commented Jan 19, 2021 at 13:28
  • \$\begingroup\$ @Finbarr nop... unfortunately, smart bulb does not comply with my need. I need one very decorative and specific bulb + one custom high-power LED. Hence, I can control two environments in my room. Of course, one project extansion is to add an ESP to include the light fine control (color temperature, intensity, etc.) inside HOmeAssitant. But I need (my wife request) a physical interface to keep basic control (without smartphone, etc.) \$\endgroup\$ Commented Jan 19, 2021 at 13:45

1 Answer 1


The simplest way is probably to use 220V Latching Relay. At each pulse, those change states and remain in position even if there is no power.

For MCU based, It's difficult to have a small implementation because you will need at least a power supply.

Arduino does have some very small boards though.

The idea is to when the system is switched on, the capacitor starts to charge. If it was off for a long time, the voltage on the capacitor will be 0V, if it was switch quickly two times in a row, the second time, the voltage will be somewhere between 0V and VCC.

Using an MCU, you can check whether this capacitor is 0V or not, if not, the switch was pressed twice.

You may need to adjust R1, R2 and C1 to have the proper timings.


simulate this circuit – Schematic created using CircuitLab

This would only reliably work only for switching twice.

Another method is to have an MCU with non-volatile memory and an RTC clock that has its own battery. You can then store the state in the NVM and the clock to know the timings.

One more method is to have a large enough input cap (like a super-cap) so that the MCU can run for a few seconds when the power is cut off so that you can count the switches.


simulate this circuit

  • \$\begingroup\$ thanks. In fact yes : I need a power stage. I think about a "non isolated" power stage thanks to capacitor to produce a 3V3 power for MCU. And yes another super cap to maintain the MCU "ON" during the second toggle switch. \$\endgroup\$ Commented Jan 19, 2021 at 12:38
  • \$\begingroup\$ Definitely I just wonder how the commercial bulb light I saw in the past, was working... :( \$\endgroup\$ Commented Jan 19, 2021 at 12:39
  • \$\begingroup\$ Probably the charging cap version, directly implemented in the LED driver or the clock one with a capacitor as the clock battery source. \$\endgroup\$
    – Damien
    Commented Jan 20, 2021 at 4:16

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.