How do I connect multiple LEDs to one push-button switch?

Thread Starter

Circuitn00b

Joined Aug 12, 2019
8
Hello, I have eight LEDs, one battery source and one normally open SPST push-button switch. I want the LEDs to light and turn off one by one in succession through the push-button switch.


So that push 1 will light LED 1 (and when the button is realeased it will turn it off), push 2 will light LED 2 (and turn it off) push 3 will light LED 3 (and turn it off) push 4 will light LED 4 (and turn it off) etc. When LED 8 has been lighted up and turned off, the process recontinue. So that the ninth push will light LED 1 (and turn it off), the tenth push will light LED 2 (and turn it off) etc.


How do I do that?
 

AnalogKid

Joined Aug 1, 2013
10,971
The simplest way is to start with a CD4017 chip. This is called a decade counter, but it actually is a Johnson counter. It has 10 outputs, and steps through them with each successive clock cycle. To that you add a small output transistor for each LED because the 4017 cannot supply very much current. Also needed is another transistor so the LEDs go out when the switch is released. Sounds like a lot, but it is a pretty simple circuit.

What is the supply or battery voltage?

How much current do you want through each LED?

ak
 

dl324

Joined Mar 30, 2015
16,788
Welcome to AAC!

+1 for CD4017. What is your supply voltage and what LED current do you want? If the supply voltage is high enough, you might be able use CD4049 to drive the LEDs.

You'll need to debounce the switch.
 

AnalogKid

Joined Aug 1, 2013
10,971
First pass at a schematic. U2 is 8 driver transistors in a single package. I think it is a more convenient part to use.

R10-C2 debounce the switch so the LEDs advance only one state per button press. R2 is relatively large because most of the capacitor current comes through R9.

Note that the signal from the switch is going into the Enable input. This is a valid use of this input. The clock and enable inputs both go to the internal clock circuits. The Clock input is non-inverting and the Enable input is inverting. By using the enable input, the clock signal is the right polarity to drive Q1 on and off with the button presses.

R2-R7 and D2-D7 are omitted for clarity. R1-R8 have no value because it depends on the value of Vcc.

If Vcc is low enough, like 3.6 V to 6.0 V, then some resistors can be deleted.

ak

LED-Stepper-5-c.gif
 
Last edited:

ElectricSpidey

Joined Dec 2, 2017
2,754
Maybe something like this.

If all of the LEDs are the same then only one dropping resistor needed, if they are different then you will need a resistor on each LED.

I left out the component values because the de-bounce will probably depend on the LED resistor/s.

The driver may be replaced with discrete NPNs or the ULN2804A depending…

This circuit also assumes the switch can handle the LED current.

A_Simple_4017_Circuit.JPG

BTW I was working on this when AK posted, wasn't meant to be competition or anything...….
 

dl324

Joined Mar 30, 2015
16,788
Neither of the proposed circuits are what the OP wants.
So that push 1 will light LED 1
The first LED doesn't turn on until after the first press of the switch.

In the proposed circuits, at power on the first LED is on without a press.

The second circuit won't work. Clock is tied HIGH.


EDIT: missed the part where the LED was only on when the switch was held on.
 
Last edited:

ElectricSpidey

Joined Dec 2, 2017
2,754
No sorry, on my circuit the LED tied to output "1" will light on the first button push, but I admit leaving out the power up start cap and diode on the reset line.

And no again, I tied the clock high because the counter is being clocked via the enable.
 

dl324

Joined Mar 30, 2015
16,788
No sorry, on my circuit the LED tied to output "1" will light on the first button push, but I admit leaving out the power up start cap and diode on the reset line.
Your circuit will turn on the first LED when power is applied (and the circuit is reset).
And no again, I tied the clock high because the counter is being clocked via the enable.
OK. I forgot that CD4017 can be clocked via the enable pin. Still need to debounce the switch.
 

AnalogKid

Joined Aug 1, 2013
10,971
Overlap happens. If the LED current is low enough and the supply voltage is high enough, then you need individual current limiting resistors to prevent reverse breakdown of the off LEDs. But with open collector/drain drivers, that is not a problem.

I thought about running the LED current through the switch, but it makes the debounce capacitor much larger. If you want to try it:

1. Disconnect U2 pin 9 from GND and connect it to switch pin 2.
2. Disconnect R1 from the Q1 collector and connect it to Vcc. Delete R2 and Q1.

ak
LED-Stepper-5-c.gif
 

ElectricSpidey

Joined Dec 2, 2017
2,754
dl324, I think you are missing the fact that no LEDs will light when the power is applied, then after the first button push LED "1" will light until the button is lifted.

Note the 4017 starts with output "0" not "1". But you do need the power on circuit to insure this.
 

dl324

Joined Mar 30, 2015
16,788
I think you are missing the fact that no LEDs will light when the power is applied, then after the first button push LED "1" will light until the button is lifted.

Note the 4017 starts with output "0" not "1". But you do need the power on circuit to insure this.
One output is always HIGH:
upload_2019-8-12_11-20-45.png

You can't use output 0.
 

AnalogKid

Joined Aug 1, 2013
10,971
The second circuit won't work. Clock is tied HIGH.
Note that the signal from the switch is going into the Enable input. This is a valid use of this input. The clock and enable inputs both go to the internal clock circuits. The Clock input is non-inverting and the Enable input is inverting. By using the enable input, the clock signal is the right polarity to drive Q1 on and off with the button presses.
ak
 

AnalogKid

Joined Aug 1, 2013
10,971
I agree with Spidey - when the circuit is first powered on, all LEDs will be off no matter which state the 4017 is in (which 4017 output is high). On the first button press, the 4017 will go to the next state and that LED will light until the switch is released.

ak
 
Top