Electronic – Turn an LED off and on with the same push button


How can I have an LED turn on when a push button is pressed, turn off when the button is pressed again, and keep its state unchanged when the button is not pressed?

I don't want the LED to oscillate if the button is held down for a while, and I want immediate action (not having to hold the button down while waiting for a capacitor to charge).

Best Answer

Assuming you don't want to do this with a simple microcontroller, I'd recommend you an easy logic gate circuit as from here:

enter image description here

Imagine Vout is low for a start. This will make the first gate (G1) output high. That makes the second gate (G2) output low, so this situation is stable.

Now, someone presses the button. That connects the high output of G1 to its input, so that the output becomes low. The low on the inputs of G2 makes the output of G2 high. We're in a stable situation again.

When someone presses the button again, the same happens, but in the opposite way: the low output of G1 is connected to its input, making the output high. That is connected to the input of G2, making the output of G2 low. We're back to the first situation.