0
\$\begingroup\$

I'm building a light indicator system with four states (All lights off, Red light on, Amber light on, and Green light on). I want to be able to go from one state to the next with just one button press, which rules out having individual on/off switches for each light, and also a rotary switch because going from Green back to Off would require switching on Amber and Red. A momentary push button is the preferred option.

I've been looking at Set/Reset Latches with NAND gates similar to the "Sequential Logic -> Flip-Flips -> SR Flip-Flop" example on http://www.falstad.com/circuit/. This example uses two two-input NAND gates where one input is pulled high and grounded on button press, the other input is tied to the output of the other NAND gate. To get this to work with four states I was thinking about using two 4012 Dual 4-input NAND gate CMOS integrated circuits, but the wiring becomes significantly more complicated compared to using a simple rotary switch.

Is there a simple way to achieve this functionality, with a type of mechanical switch or an integrated circuit that just takes the 4 inputs and has 4 outputs?

\$\endgroup\$

closed as too broad by Dmitry Grigoryev, laptop2d, brhans, Daniel Grillo, Rev1.0 Dec 20 '16 at 10:18

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ A small MCU is the simplest way to implement this, although not the easiest. \$\endgroup\$ – Ignacio Vazquez-Abrams Dec 12 '16 at 5:50
  • \$\begingroup\$ A state machine, learn how to design the machine, simplify it with digital logic rules and then find hardware to implement it. Hardware could be discrete components, a PLC or micro controller. \$\endgroup\$ – laptop2d Dec 12 '16 at 17:08
2
\$\begingroup\$

You could use a CD4022 Octal Counter, with fully decoded outputs 0 to 7, and tie output 4 to RESET so it wraps around after 4 counts instead of 8. It is available in a 14-pin DIP from Digi-Key for 52 cents. You will want to provid some debounce circuitry on the input so it advances only once per push-button press.

enter image description here

Since I am using the 4000B CMOS family, the circuit will work with any VCC voltage from about 5V to 18V (5V minimum, not 3V to allow a little headroom for the LEDs). For this reason I haven't listed any values for R4 through R6, as they will depend on VCC and the LEDs chosen.

If you want to use a SPST button instead of SPDT, you will need a different debounce circuit. There are hundreds of references on the web for this. A good one is here, which starts off describing the SR latch used here, as well as a reliable circuit for use with a SPST switch.

\$\endgroup\$
  • \$\begingroup\$ In this circuit does each button press move the state forward by 1, i.e 0: Off + 1 = 1: Red, 1: Red + 1 = 2: Amber, 2: Amber + 1 = 3: Green? If so, is there a way to decrease the counter so I could go from 3: Green back to 2: Amber (-1) without going + 1 = 0: Off + 1 = 1: Red + 1 = 2: Amber? If not I'm thinking each button press (Off button, Red button, Amber button, Green button) would need to reset the decade counter then fire a series of pulses to reach the desired state, i.e Green button press does a reset then sends 3 pulses. \$\endgroup\$ – Ryan Jenkin Dec 12 '16 at 23:54
  • \$\begingroup\$ @RyanJenkin Yes, it moves only 1 ahead for each button press, and when it reaches green, it goes back to off (resets the counter). That is the way I interpreted your question. Going backwards would require an up/down counter, a different circuit, and another pushbutton. \$\endgroup\$ – tcrosley Dec 13 '16 at 0:03
1
\$\begingroup\$

You could implement a ring counter like below: -

enter image description here enter image description here

This website is very good at explaining the theory of a ring counter and is where I stole the pictures from. It also gives you other options like a johnson counter (as mentioned by @tcrossley in his answer).

Another way is to use a counter like below but add gates so that outputs lower down get deactivated when an output higher up the chain become active: -

enter image description here

Pretty picture stolen from here

\$\endgroup\$
0
\$\begingroup\$

You can use a rotary switch that allows unbounded 360 rotation, e.g. going from state 4 to 1 without "turning it back"

\$\endgroup\$
  • \$\begingroup\$ This is pretty close to what I'm after, it's simple to wire up, the disadvantage is that I can't jump directly between Off and Amber, or Green and Red. \$\endgroup\$ – Ryan Jenkin Dec 12 '16 at 23:23

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