Make a momentary switch control a toggle

Here's another alternative with two inverters and debouncing:

Two inverters

For logic output, only the two inverters, RC, and feedback resistor are needed:

enter image description here

NC7WZ14 is $0.06 with 2 inverters, small 6-pin package, and Schmitt trigger inputs, though I think this circuit doesn't even need Schmitt inputs because of the RC. Also it can drive 24 mA, so you could connect the LED directly to it if you're using an LED for whatever reason.

Also shown here and here as a toggle touch switch.

I think the feedback resistor has to be much smaller than the center resistor to prevent it from oscillating if you hold down the button, because the low-impedance connection to the output will prevent the capacitor from charging to the middle voltage until you let go.

Variants are described at Press ON - Press OFF soft latching circuits:

AND gate variant


One possible method:

Use an RC to debounce the switch

RC network connected to momentary switch to debounce

and then feed it into a D flip-flop with the output feeding back to the input to implement a T flip flop.

D flip-flop configured as toggle flip-flop

The D flip-flop needs to be positive edge-triggered only, and needs an inverted output.

  • The 8-pin NC7SZ74 should work, is very small, and costs $0.12 in quantity.
  • The 74HC74 is a dual D flip-flop with 14 pins for $0.05.

Are there any issues with this? The switch would need to be held down for a short period of time for the rise time to trigger the clock input, which is probably good. If you hold down the button, it will only trigger once, which is good. Is there a better way to debounce in the feedback loop or something instead?


Or you could do it with a single tiny 6-pin microcontroller and no other components. It might cost a tiny bit more, but it's simpler and takes up less space. Debouncing a switch in software is simple, then it's just a manner of storing a boolean if the output should be high or low. The smallest version of this mcu comes in a 2mm x 2mm surface mount package. In large quantities it might be $0.50.

toggle schematic