# Minimum design for controlling 2 LEDs to light either one or both?

I am an absolute beginner in electronics. So far I have created a circuit with 2 LEDs and 2 SPST pushbuttons, each controlling a different LED. Very simple, you should get the idea without me drawing a circuit.

I've been trying to figure out how to add a third pushbutton, which would control both two LEDs at the same time, without altering the functionality of the two existing two pushbuttons.

Is it even possible to achieve this with 3 SPST pushbuttons, without adding any other components? If not, I am interested in learning what would be the simplest design to achieve this. Thank you.

• It depends. What are your requirements? What should the third button exactly do? A truth table would help. – marco-a Jan 7 '16 at 23:24
• The simplest solution is entirely different from the minimal GPIO count solution. Simplest is to just allocate one GPIO per switch and one GPIO for each LEDs. Minimal number of GPIOs is more complicated requiring more complex software and often entails extra components outside the MCU boundary. – Michael Karas Jan 7 '16 at 23:56
• @MichaelKaras I don't see any CPU in this question, just switches and lights. – Icy Jan 8 '16 at 8:39
• would be easy if your third button was DPDT, or add a DPDT relay driven by your third SPST switch, but as d3l says a truth table of what you want to achieve here would help. – Icy Jan 8 '16 at 8:41

No. Without adding extra components (Diodes) you can not use SPST buttons.

simulate this circuit – Schematic created using CircuitLab

If you use a DPST or DPDT switch instead, quite easy to find, you can avoid the diodes. You would ignore the extra pins on the DPDT switch.

simulate this circuit

Sure, it's possible. LEDs are nonlinear and we can take advantage of that:

simulate this circuit – Schematic created using CircuitLab

When SW1 or SW2 are pressed, the respective LED will light, however the opposite one sees less than half the voltage and will not pass any significant current (so will emit no light). Pressing SW3 causes both LEDs to illuminate.

It wastes a bit of current because of R4 (~3x the current for one LED rather than double to light two LEDs) but that's a small price to pay for a solution.

• Of course that requires two extra resistors, and depending on the resistance and voltage values will still cause an led to light (very little current is needed sometimes), might as well use the diode setup instead. – Passerby Jan 8 '16 at 1:42
• @Passerby This circuit might be better if the supply voltage is close the the LED Vf. It's easier to use a gate chip or transistors or whatever. – Spehro Pefhany Jan 8 '16 at 1:54