6
\$\begingroup\$

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).

\$\endgroup\$
  • \$\begingroup\$ You can of course always use an Arduino. \$\endgroup\$ – user17592 Apr 8 '13 at 17:55
11
\$\begingroup\$

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.

\$\endgroup\$
  • 2
    \$\begingroup\$ I'll add that the 0.01uF capacitor causes the circuit to power-up in a defined state - the 10nF is stopping the input to G1 (left) from rising quickly and so G1's output will want to be high and G2's output will be low. \$\endgroup\$ – Andy aka Apr 8 '13 at 17:53
5
\$\begingroup\$

The simplest way is with a latching pushbutton such as this one Push it and it turns on and stays on. Push it again and it turns off and stays off.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.