# "rolling" or increasing multiple LEDs from one output pin

Hi all.

I'm trying to think of a way to control a "stack" of LEDs somehow -- more LEDs than there are output pins -- from one or two output pins.

That is, given a row of N LEDS (let's just pretend its 9):

``````0  0  0  0  0  0  0  0  0
a  b  c  d  e  f  g  h  i
``````

Is there a way to light up X of them at a time without attaching each LED to a separate output pin?

So a command LIGHTUP(5) would light 5 of them (duh):

``````1  1  1  1  1  0  0  0  0
a  b  c  d  e  f  g  h  i
``````

I was thinking at first somehow using the analog pin to up the voltage to "overflow" each LED I wanted, but that's not how electricity works.

This could be a wiring solution or a code solution.

I'm using an UNO, but I don't know if that makes a difference at this point.

Any thoughts or insight would be appreciated.

Thanks!

No, you can't "up the voltage" but you can connect more than one LED per pin. Read about Charlieplexing here and elsewhere. Make sure you use current limiting resistors.

There are also bar-graph LED displays and bar graph driver chips that don't require an Arduino. Finally a port expander chip gives you 16 extra outputs at the expense of two.

WS2812 LED connected in series can be controlled by one pin

You can do it with a [u]shift register[/u] but it usually requires at least two pins. One for "clock" to tell it when to shift and one for "data" or to set-up the initial condition, and/or to clear.

But, it's possible to make a traditional chase effect by setting-up the initial condition, then make a loop by feeding the output (last register) back-into the input (first register). Or, you can make a "Johnson Counter" by inverting the output before feeding it back to the input. None of that takes a microcontroller, all you need is a shift register (or flip-flops) and a clock (like a 555 chip).

With 3-pins (data, clock, latch) you can address an almost-unlimited number of LEDs. I've used six 8-port [u]MAX6968[/u] LED driver chips to address/control 48 LEDs. This could have been done with 3-pins but it's a stereo sound-activated lighting effect with 3 daisy-chained driver chips on each side. The clock & latch pins are shared, but there are separate data pins for left & right so I used 4 output pins.

Or, with Neopixels you can address an almost unlimited number of LEDs with just one control line/pin.

If you think about it... The whole internet runs serially so "philosophically" all you need is one transmit pin and one receive pin. Or, all of cable TV comes over one wire and a cable-modem works over one wire...