Electronic – Push button for different actions in every press

buttonledtoggle switch

I'm trying to learn some electronics and I have something in mind that I don't know if it is possible to achieve.

I've worked before with micro-controllers (Arduino, etc) and I know I would be able to do this with code, but I would like to know if this is possible without any code/micro-controller.

enter image description here

I would like to have a push button and 3 LEDs.

  • First time you press the button, first LED will light.
  • Second time you press the button, second LED will light (and the first one will be off).
  • Third time you press the button, third LED will light and the second one will be off.

If you push it again, every LED will be off. And then the process will start again with every press of the button.

I hope I was able to explain it correctly

Is this possible??

Thanks a lot.

Best Answer

Yes this is possible to implement with digital logic chips. The circuit requirements that you describe would require a state machine design that has four states, one for each of the LED on states and one for when they are all off. One possible design would use four D-type flip-flops designed to be connected into a chain to permit one flop to be set at a time whilst the others are cleared. Another design would require just two D-type flip-flops to count in binary as 00, 01, 10 and 11 cycling back to 00. Appropriate logic gates would then be used to decode states 01, 10, and 11 to turn on the three LEDs.

There are some specialized counter chips available that can make this digital design take less parts than a discrete gates and flip-flops design. One such chip is the 74HC4017. This specialized counter has ten outputs with only one active at a time. Clocking the part from a debounced transition of your switch would advance the active output to the next one. Since you only want four states as opposed to ten then you will have to arrange some additional circuitry such that when the counter has advanced to the fifth output active that wraps back to the master clear input to set the counter state back to the first state.

In the end this problem is easily solved with a microcontroller as you commented to in your question. The MCU can do much more that the discrete circuit in that you cam easily change the state sequence design of the LEDs if you so desire at a future time. It can also take care of debouncing the switch.