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

Discussion in 'General Electronics Chat' started by Circuitn00b, Aug 12, 2019.

  1. Circuitn00b

    Thread Starter New Member

    Aug 12, 2019
    8
    0
    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?
     
  2. AnalogKid

    AAC Fanatic!

    Aug 1, 2013
    7,932
    2,240
    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
     
  3. dl324

    AAC Fanatic!

    Mar 30, 2015
    8,521
    2,049
    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.
     
  4. AnalogKid

    AAC Fanatic!

    Aug 1, 2013
    7,932
    2,240
    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: Aug 12, 2019
    ElectricSpidey likes this.
  5. ElectricSpidey

    Active Member

    Dec 2, 2017
    626
    152
    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...….
     
  6. dl324

    AAC Fanatic!

    Mar 30, 2015
    8,521
    2,049
    Neither of the proposed circuits are what the OP wants.
    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: Aug 12, 2019
  7. ElectricSpidey

    Active Member

    Dec 2, 2017
    626
    152
    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.
     
  8. dl324

    AAC Fanatic!

    Mar 30, 2015
    8,521
    2,049
    Your circuit will turn on the first LED when power is applied (and the circuit is reset).
    OK. I forgot that CD4017 can be clocked via the enable pin. Still need to debounce the switch.
     
  9. AnalogKid

    AAC Fanatic!

    Aug 1, 2013
    7,932
    2,240
    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
     
  10. ElectricSpidey

    Active Member

    Dec 2, 2017
    626
    152
    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.
     
  11. dl324

    AAC Fanatic!

    Mar 30, 2015
    8,521
    2,049
    One output is always HIGH:
    upload_2019-8-12_11-20-45.png

    You can't use output 0.
     
  12. ElectricSpidey

    Active Member

    Dec 2, 2017
    626
    152
    The circuit with power up reset.

    A_Simple_4017_Circuit_2.JPG
     
    Last edited: Aug 12, 2019
  13. ElectricSpidey

    Active Member

    Dec 2, 2017
    626
    152
    It doesn't matter which output is high...the LEDs only light when the button is closed.
     
  14. crutschow

    Expert

    Mar 14, 2008
    22,492
    6,588
    I would add a small resistor (say 10Ω) in series with the switch to avoid the high peak charge current from the capacitor which could degrade or weld the contacts.
     
    narkeleptk likes this.
  15. dl324

    AAC Fanatic!

    Mar 30, 2015
    8,521
    2,049
    OK. I missed that.

    You still need to debounce the switch and the enable isn't a Schmitt input.
     
  16. AnalogKid

    AAC Fanatic!

    Aug 1, 2013
    7,932
    2,240
    ak
     
  17. AnalogKid

    AAC Fanatic!

    Aug 1, 2013
    7,932
    2,240
    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
     
  18. Circuitn00b

    Thread Starter New Member

    Aug 12, 2019
    8
    0
    Thank you for your answers, I’m using a 9 volt battery. I made a short movie that explains what I’m trying to achieve. The LEDs in the movie aren’t connected with wires, but pretend that they are.. Here’s the movie: https://streamable.com/d9qf7
     
  19. ElectricSpidey

    Active Member

    Dec 2, 2017
    626
    152
    Assuming they work correctly, both circuits will do exactly what you want.
     
  20. AnalogKid

    AAC Fanatic!

    Aug 1, 2013
    7,932
    2,240
    Final (?) update. This one puts around 13 mA through each LED.

    ak
    LED-Stepper-5-c.gif
     
    Tonyr1084 and narkeleptk like this.
Loading...