Go Down

Topic: 100 LEDs (Read 5374 times) previous topic - next topic


Hello everyone,

I am a complete n00b, but it looks like Arduino is exactly what i'm looking for, to complete a project i am workingon.

I build my own picture frames. The one I am currently working on requires LED's running around all 4 sides of the frame. It will require about 96 LED. I would like each LED to stay eliminated for 5 seconds, then move on to the next LED. So in the end it will go all the way around the from. Which Arduino device would work best for this? Is that too many LED's?

any help would be pronominal.




Check out this tutorial, how to increase number of outputs:
http://www.arduino.cc/en/Tutorial/ShiftOut  Any 5V board will be o'k. There is only 3 pins required.


Okay since you are a newbie i'll explain everything.

As magician said, you could use the ShiftOut which uses the 74HC595.  A common shift register.  Although heres the problem with doing that.  If you were to use just shift registers, you would need 12 of them!  Now that is just way too cumbersome when you just want to turn one led on at a time.  So heres a better way.

Take a look at these http://www.sparkfun.com/products/299
Its a multiplexer,  what it does is take in 5 HIGH or LOW signals.  Thats what a 74HC595 outputs right?  well heres what you can do.  connect 2 74HC595s together and then hook up a few multiplexers to those.  Now you will have some overlap, well you can just use your extra arduino pins to control those.  That way you cut down your chip count down from 13 to about 6 or 7.  Good luck!
Accelerate to 88 miles per hour.


96 LEDs < 100 LEDs = 10*10 LEDs. Thus you can drive this directly without a multiplexer. The only requirement is that you do not exceed the current limit of 40 mA per IO pin. Thus either drive the LEDs with at most 4mA (actually 40mA with a 10% schedule) or use suitable drivers.

Check out my experiments http://blog.blinkenlight.net


yeha like udo said you can probably do this via an LED matrix idea (though going 10x10 is probably a bit annoying also wouldnt you need more then an uno to do 10x10, well maybe if you use analogs as digital pins. yeah dont do that))
One thing you could do to easy it up, make the matrix of 96 pins with 3 shift regs, so 16 x 8 will drive up to 128 LEDs, then it would be easy enough to make each pair of control lines from one register correspond to the top, left, bottom or right side of the picture frame. Or you could bruteforce it and do 12 shift registers, in 4 banks of 3, each bank again corresponding to a side of the frame (would be easiest to code for a newbie, but I'm finding that LED arrays can be interesting, so should probably give that a try)

I'll draw out a diagram, later when i get my camera, of the 3 ways I'd set it up using shift regs, hopefully they might be a bit of help.

in response to funky though... are multiplexers liek that really a newbies thing to play with. First he'll need the breakout board for that most likely, which is almost $5 each. That or learn to surface solder which isn't really a rookie level thing to do (I sure as hell cant do it nicely yet). then on top of that, in array form he'd need 2 of them (16x16 array), or if he were driving the leds directly off the multiplexers hed need 6 to control the actual outputs (each one requiring 4 pins to run), and then hed need another 2 to control the 6 multiplexers because theres not enough arduino pins. Then the code makes my head hurt to think about. Basic shift register and a regular array are probably the guys best bet in this particular case.


Jul 03, 2012, 07:15 pm Last Edit: Jul 03, 2012, 07:38 pm by CrossRoads Reason: 1
You guys are going overboard. Can do this with NO shift registers, and just one ULN2803.
Uno has 20 IO.
Use 12 to Drive rows of 8 anodes.
Use 8 to drive columns of cathodes, buffered by the ULN2803.
Arduino drives anode(s) high, ULN2803 sinks current from the cathodes.
If Truly just turning on 1 LED only, can skip the ULN2803 even as only 20mA will need to be sunk at a time.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


You guys are going overboard. Can do this with NO shift registers, and just one ULN2803.
Absolutely right.  Only one led at a time, no brightness control. I've been busy with shift registers lately, they just stick to my mind  :D


You guys are going overboard. Can do this with NO shift registers, and just one ULN2803.
Uno has 20 IO.
Use 12 to Drive rows of 8 anodes.
Use 8 to drive columns of cathodes, buffered by the ULN2803.

that may be but. meh actually, don't have any of those yet, thats probably the best idea, though it will use up all of his pins, so he better not be planning on doing anything else in that setup.
btw heres the link for the ULN2803


True, you could use the digital pins 0 - 14 and the analog pins A0-A5, totaling 20 pins and could use some circuit work instead.  I was merely stating my response since the OP is new to this and I figured 0's and 1's would be better instead of possibly getting confused with the HIGH's and LOW's for sink or source...although i guess that would be easier, haha.
Accelerate to 88 miles per hour.


If you're only turning on one LED at a time, this sounds like an excellent application for Charlieplexing. Requires no additional hardware (beyond current-limiting resistors) and 11 output pins.


"this sounds like an excellent application for Charlieplexing."

And that'd be oh so much easier to code too ;)
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


I think it would indeed be easy to code.  I believe that this will sequentially light 96 LEDs, using Arduino pins 2 through 12:
Code: [Select]
void setup() {
  for (uint8_t i=2;i<=12;i++) {

void loop() {
  uint8_t n = 0;
  for (uint8_t i=2;i<=12;i++) {
    for (uint8_t j=i+1;j<=12;j++) {
      if (n == 96) {
    if (n == 96) {

I've run this code on my Uno, and tested its operation by examining the data and direction registers for ports B and D for each virtual LED, in place of the delay function shown in this code.  It looks like there's always only one LED on, and it's the one that I expect.  So, I'd say that for this code, my confidence is high.

Getting the code this simple requires the LEDs to be wired in a conceptually natural way.  Wiring it, though, would be a beast of a job.

I've fiddled with finding an LED arrangement that simplifies the wiring at the expense of code complexity.  After all, at the worst I'd have to create an array of output patterns, and index it sequentially.  But I haven't found any method that's particularly satisfying.  I'd very much like to see others' experience and thoughts on wiring arrangements for charlieplexed LEDs.


this may help you...  I was also working on a non-cube/non-matrix configuration too, and couldn't find anything that was linear...

So I made one.

Since I made this drawing, and then built the hardware/software to match, I have learned that the order is a bit messed up - I should have done (pins) a-b,a-c,a-d,a-f,a-g... b-c,b-d,b-e   and so on...

here's some code:

Code: [Select]


#define A 4
#define B 5
#define C 6
#define D 7
#define E 8
#define J 9
#define G 10
#define H 11
#define I 12


int c[72][2] =
    {A, B}, {B, A}, {B, C}, {C, B}, {C, D}, {D, C}, {D, E}, {E, D},
    {E, J}, {J, E}, {J, G}, {G, J}, {G, H}, {H, G}, {H, I}, {I, H},
    {A, C}, {C, A}, {B, D}, {D, B}, {C, E}, {E, C}, {D, J}, {J, D},
    {E, G}, {G, E}, {J, H}, {H, J}, {G, I}, {I, G}, {A, D}, {D, A},
    {B, E}, {E, B}, {C, J}, {J, C}, {D, G}, {G, D}, {E, H}, {H, E},
    {J, I}, {I, J}, {A, E}, {E, A}, {B, J}, {J, B}, {C, G}, {G, C},
    {D, H}, {H, D}, {E, I}, {I, E}, {A, J}, {J, A}, {B, G}, {G, B},
    {C, H}, {H, C}, {D, I}, {I, D}, {A, G}, {G, A}, {B, H}, {H, B},
    {C, I}, {I, C}, {A, G}, {G, A}, {B, H}, {H, B}, {A, I}, {I, A}

void setup()
//clear all Charlipins

  pinMode( A, INPUT );
  pinMode( B, INPUT );
  pinMode( C, INPUT );
  pinMode( D, INPUT );
  pinMode( E, INPUT );
  pinMode( J, INPUT );
  pinMode( G, INPUT );
  pinMode( H, INPUT );
  pinMode( I, INPUT );

void loop()

//  do the math for timing and such.

lightLed(c[X]);   // X is the LED to be lit...

// blah blah


void lightLed( int pins[2] )

    pinMode( pins[0], OUTPUT );
    digitalWrite( pins[0], HIGH );
    pinMode( pins[1], OUTPUT );
    digitalWrite( pins[1], LOW );


now this only goes to 72 LEDs.   you'd have to add another row (or 2?) to the drawing for 96 leds.

Charliplexing does make the wiring/soldering a bit of a pain in the butt, but costs are reduced and the programming is pretty simple too, once you have the array setup.

Also, I'm a bit of a noob myself, an there is probably a better way to do what I am doing, so maybe someone will chime in and set both of us straight...


Jul 17, 2012, 02:57 am Last Edit: Jul 17, 2012, 04:30 am by ThePsuedoMonkey Reason: 1
Wouldn't it be far easier and cheaper to use a few decade counters and a timer?  You wouldn't need any code that way!

Edit: you could even use just one decade counter if you have (# of LEDs / 10) lit LEDs, and the lit ones could even be non-sequential.  This is pretty common in LED chasers, and there is a lot of info about them floating around.


Jul 17, 2012, 03:12 am Last Edit: Jul 17, 2012, 03:16 am by fkeel Reason: 1
using addressable LED strips might be a simple solution as well:



one problem so many solutions :-)

edit: or if your more adventurous http://www.alibaba.com/product-gs/563354372/2012_5050_SMD_Programmable_LED_Strip.html?s=p

Go Up