0

We have 30 LEDs in a row, and we want to turn them on left to right. However there are way to many for the Arduino to have each one on a different pin.

Is there an IC that can take a binary output, and output in base 1?

Phil Frost
  • 56,804
  • 17
  • 141
  • 262
  • 1
    [Why would you EVER ask about that instead of asking about the LEDs?](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) – Ignacio Vazquez-Abrams Dec 05 '14 at 14:08
  • What is base 1? – Tut Dec 05 '14 at 14:14
  • 4
    Base 1?! LOL. Actually stop and *think* about it. How would a number system work when the only digit you have is 0? – Olin Lathrop Dec 05 '14 at 14:23
  • 2
    If there isn't a binary to base 1 IC, it would seem like you could actually make one pretty easily, with a wire to ground and no inputs. – Scott Seidman Dec 05 '14 at 14:24
  • 4
    @OlinLathrop: http://en.wikipedia.org/wiki/Unary_numeral_system – Ignacio Vazquez-Abrams Dec 05 '14 at 14:26
  • @Ignac: That's not really base 1 using the same scheme we assume for base 2 and higher. In a base N system, you have digits from 0 to N-1. You can't extrapolate this system to base 1. It's not right to call a basic counting system "base 1" without making a special case of that name. – Olin Lathrop Dec 05 '14 at 14:47
  • Possible duplicate: http://electronics.stackexchange.com/questions/1609/how-many-individual-lights-can-an-arduino-control – clabacchio Dec 05 '14 at 15:03
  • 5
    There are 11 kinds of people in this world, @OlinLathrop. Those that understand unary numeral systems, and those who don't. – Phil Frost Dec 05 '14 at 15:32
  • Anyway, can the OP identify what "a bunch" means? – Phil Frost Dec 05 '14 at 15:34
  • 1
    Look up "charlieplexing" on wikipedia. – John U Dec 05 '14 at 16:40
  • @IgnacioVazquez-Abrams Thanks for the link- I didn't know any better. I guess because my LEDs only have to light up left to right rather then in an arbitrary pattern I thought this was a special case. I'll get better at asking questions, **thanks for the answers everyone**. – avery-whitaker Dec 08 '14 at 05:22
  • @PhilFrost 30, which I was thinking would take 5 digital outputs (2^5=32) – avery-whitaker Dec 08 '14 at 05:23

5 Answers5

6

LEDs like that are commonly driven by shift registers. A shift register takes 3 inputs from the arduino (Data, Enable and Clock), takes a (for example) 8 bit number, then outputs it on 8 different pins. One example is like this: Shift Register 8-Bit - 74HC595

dscharge
  • 390
  • 1
  • 2
  • 7
2

You really should dive into charlieplexing. With this technique it is possible to drive many leds with just a few pins. The formula is n x n-1. Meaning that with 4 pins you can drive 4 x (4-1) = 12 leds. Imagine that 12 leds with just 4 pins. With 5 pins you can therefore drive 5 x (5-1) = 20 leds.

With charlieplexing you can blink each of these leds individually or even have them burn all at the same time. It involves some really ingenious wiring and software, But there is a lot of documentation on that in the net. just search google for arduino and charlieplexing.

I made an hourglass with 20 leds just using an Attiny85 and a Larson scanner with 12 leds also using an Attiny85.

I am on the verge of writing a detailed series about charlieplexing on my website, but hey that will take a while. http://lucstechpage.weebly.com/

m.Alin
  • 10,638
  • 19
  • 62
  • 89
1

What you're looking for is a decoder or a multiplexer.

clabacchio
  • 13,481
  • 4
  • 40
  • 80
1

The right answer is a to take the the number of LEDS you have and call that the number of bits of storage you need. If you have 8 LEDs you need to interface to 8 bits of external storage. You then need to find an interface protocol with an equal number to or less amount of pins than you have. If you only have 3 external GPIO pins, you could go with the SPI interface, or the IIC interface.

Consider this part as a solution:

http://www.maximintegrated.com/en/products/interface/controllers-expanders/MAX7314.html

Jotorious
  • 659
  • 3
  • 10
0

Okay, thermometer code. I don't know of any off-the-shelf decoders for that.

If you are into programmable logic, I think a single CPLD such as the XC2C64 could be programmed to drive (say) 50 LEDs with a 6-bit input. That gives you static drive.

An easier and cheaper way is to use multiplexed drive- drive 8 source drivers (UDN2803 or similar) with one port of your micro and 8 sink drivers (ULN2803) with another port. That will allow up to 256 LEDs to be driven with only 16 port pins, two chips and 8 resistors.

The source drivers may have to be MOSFETs or something else hefty, as they must conduct the average current of a single LED * 16 (with 12.5% duty cycle). The sink drivers must handle the average current of a single LED * 8 (but all of them may be on at once). Layout may be more convenient using a shift register and static drive- the matrix layout is better for a rectangle, not so good for a linear bar graph.

Spehro Pefhany
  • 376,485
  • 21
  • 320
  • 842