Fastest Way to Controlling 50+ LEDS

Hey all,

I am very new to all types of hardware programming and interfacing, and I've come across a little project I have to do. I know how I want it to work, and it doesn't sound like it should be too complicated to get it done. A lot of people suggested I went with the Arduino, so I've purchased a development kit and I'm ready to get started. However, I have some questions in regards to how I'd go about implementing it.

This it what I need to do:

My computer should read from an XML file or a database which contains information on when to turn on which LED and for how long. It then sends this information to the Arduino, which is connected to an array of about 50 LEDs.

I've been told I will need a multiplexer or some sort of chip to expand my outputs to the number of LED's I need (50 or more). However, being new to all of this, I'm at a bit of a loss of where to start. My main problem not the lack of appropriate reading material, but the absolute abundance of it. With this in mind, I would like to know if any of you could be as kind as to recommend me a single book or tutorial that covers all or most of what I need to know in order to get this working. I realize I may sound a little lazy for wanting to tackle this with a single book or tutorial, but for the record, I do not plan on making a career out of this nor am I particularly interested in learning all in-depth details of it apart from the absolute necessary. In other words, I would like to get this over with in the quickest way possible. If you have any thoughts or suggestions, I would be happy to know.

Thanks!

This may not be the best option for this situation but its a good starting point and will give you an idea of what your about to get into.

There are other, maybe even better, chips that will expand the I/Os as needed. You may have to use several chips strong together. Also with that many LEDs you may have to rely one an exterior power source.

Thanks for your reply, digimike.

This sounds a little more complicated than I had imagined. :-/ Would you be aware of any shortcuts? Say, a pre-made board or "add-on" for Arduino that lets me just plug-in all the LEDs and not worry so much about all this hardware stuff? The software part of the project is already a little challenging, so I was hoping to concentrate most of my efforts on that.

As far as I was able to tell, the 74HC595 allows for 8 LEDs to be connected to it. Would I actually need 10 of these if I wanted 80 LEDs, for example?

Thanks again.

Would I actually need 10 of these if I wanted 80 LEDs, for example?

Yes if you have each LED connected to a controller pin. Now there are other methods to connecting a bunch of LEDs to the arduino. You could use row and column scanning to control 2 matrices of LEDs in a 5x5 matrix. In this example it uses an 8x8 matrix but this shows you how you would need to connect the LEDs together and how to program for them.
http://arduino.cc/en/Tutorial/RowColumnScanning

Here is a video of what cane be done.

This sounds a little more complicated than I had imagined.

Yep that's life, nothing worth doing is normally simple.

What you want sounds very much like a monome without the input switches.
My take on these is:-
http://www.thebox.myzen.co.uk/Hardware/Econo_Monome.html

or
http://monome.org/
for the real thing.

Thanks again for the the reply digimike. I re-read this link you sent (http://arduino.cc/en/Tutorial/RowColumnScanning), and it doesn't seem to be all that complicated on second thought.

I still have a question, if you don't mind. If I want to work with 64 LEDs in an 8x8 matrix, just like the example on the above link, will I need an external power source? Using an 8x8 matrix seems to take a lot less work, money, and just seems simpler than using a bunch of 74HC595's to achieve the same result. Could there some hidden complexity that I have failed to see, or is this really the case? I'm still waiting for my Arduino to arrive in the mail, so I can't go try it and figure it out for myself just yet.

Grumpy_Mike, I believe I will just try to work with an LED matrix, but I really appreciate your input.

Thanks for your time.

Yes you will need an external powersupply, especially if many of the LED's will be on at the same time.

The matrix approach makes totally sense in your case, and it has been done over and over so both the software part and hardware part is well described. Just google Arduino and LED matrix, or search the forum (and the playground) for same. You will find all you need.

You will of course need some piece of software running on the PC that can send the required information over to a serial port to Arduino.

Could there some hidden complexity that I have failed to see,

Yes - using a matrix you have to continually refresh the matrix at least 30 times a second irrespective of whether the pattern changes. With the shift registers you only clock out the data when you want the pattern to change.

There are an awful lot of people all of a sudden wanting to control 50 LEDs are you all in the same class?

Yes - using a matrix you have to continually refresh the matrix at least 30 times a second irrespective of whether the pattern changes. With the shift registers you only clock out the data when you want the pattern to change.

There are an awful lot of people all of a sudden wanting to control 50 LEDs are you all in the same class?

In what way would refreshing the matrix 30 times per second be considered a complexity? (I don't mean to challenge your word, I am genuinely asking because I don't know). In the guide posted by digimike, there is a refreshScreen() function, which seemed pretty straight forward. Isn't that what this function does? Is there more to this refreshing than just this function?

I am not in the same class as any of these other people. I am the only person in my class doing such a project, and in fact I had no idea that there are other people interested in this at the moment.


Again with this same example in mind, I am a little confused as to where the code shown on that page comes into play. If I have a flash or delphi user interface, for example, would this code serve as a sort of library/set of functions accessed by flash/delphi in order to talk to the Arduino? If not, when/how is it used?

This example seems to be geared towards the Lumex LDM-24488NI Matrix. If I were to build my own matrix using individual LEDs, would this example still apply, or would it be completely useless?

These may all be questions which can be answered through a google or forum search, as MikMo suggested, but all the information is usually scattered, and 99% of the time I become completely lost and unable to figure out what's what. I may be looking at the answer I need right in the face, but I unable to decipher it simply because the majority of content I find is geared towards people who already have a basic understanding of how to work with the Arduino.

Anyways, thank you all for your input so far, and I would greatly appreciate any further guidance you can spare.

In what way would refreshing the matrix 30 times per second be considered a complexity?

Because it has to be done regularly, this means that it can't wait for something else to finish. This affects the way you write the rest of the code and while this results in a better way to write code it is not always the most obvious way the code is written. If it is not done regularly then the display will appear to flicker. The example code you site is not very good at being regular, it simply refreshes the display when ever it can not at the 4mS interval you need to keep an 8X8 matrix flicker free. The matrix consists of 8 rows so a row needs to be done every 8 * 30 times a second.

I am a little confused as to where the code shown on that page comes into play.

You would use the main loop and replace the readSensors();
call with a call to a function you write to receive a pattern from Processing. Remember you can spend no longer than 4mS in this routine or else it will flicker.
If you get more advanced you could trigger the calling of refreshScreen(); from an internal timer trigged interrupt.

Because it has to be done regularly, this means that it can't wait for something else to finish. This affects the way you write the rest of the code and while this results in a better way to write code it is not always the most obvious way the code is written. If it is not done regularly then the display will appear to flicker. The example code you site is not very good at being regular, it simply refreshes the display when ever it can not at the 4mS interval you need to keep an 8X8 matrix flicker free. The matrix consists of 8 rows so a row needs to be done every 8 * 30 times a second.

In the project I have in mind, the LEDs will not work as a display. Only a few LEDs (between 1 and 5) will be on at a time, for a period no longer than two seconds. I suppose what you described will not be as much of a problem in my case?

I was also wondering if the Arduino Mega would be more challenging for a begginner, or if would it actually make things easier for controlling a 12x12 LED matrix, for example. I can't find any information on running a matrix that size with the Arduino Mega. Everything I find makes use of a series of multiplexers with the standard Arduino, but this does not seem like it would be necessary with the Mega.

Thanks again.

You still need external chips / components to get the current drive for a 12X12 matrix. In terms of raw pins then yes a mega would make things easer as it would give you the 24 pins you need without you having to do anything else.

A 12X12 is an unusual size but the principals of multiplexing are just the same as for any other size, so just extend the 8X8 stuff.
This ups the refresh rate to 30 * 12 = 360 times a second or once every 2.7mS.

(I am at work, and don't have access to the password to my original account)

Grumpy_Mike, you mentioned I'll have to use external components for powering the LEDs. I have tried searching google, the Arduino Forums, the Playground, the FAQ, and the starter guide, and nothing I find is helpful on figuring out how to power LEDs from an external source. Perhaps I am using the wrong search terms (arduino external power), but most of the things I find are related to Arduino's USB/External Power connector, which is not what I should be looking for, correct? Would you happen to know of any schematics or reading material that would help me figure out how to do this? I am importing the Arduino from the USA, and I really can't risk frying it multiple times until I figure out how to work the power for the LEDs.

Thanks.

Have a read of my stuff:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html

http://www.thebox.myzen.co.uk/Tutorial/LEDs.html

http://www.thebox.myzen.co.uk/Workshop/Motors_1.html
Motors are just like LEDs in the respect that they are just an external load.
Also look up "current source" and "current sink"

Finally for a look at how I sourced and sunk current for an LED matrix look at:-
http://www.thebox.myzen.co.uk/Hardware/Econo_Monome.html

Grumpy_Mike, I came across a guide where someone shows how to control 128 LEDs (two 8x8 LED matrices) with an Arduino Mega, and he did not list any external power supplies/current drive components in the list of used items:

  • Arduino Mega
  • Breadboard or prototyping shield. I'm using Smart Projects' proto shields, which were designed at the same time as the Mega itself. I love them.
  • 8×8 LED matrix. I got mine in a surplus shop in China, but you can also get them from most electronics retailers
  • male pin headers
  • female pin headers
  • Wires

Here's the link: http://www.tigoe.net/pcomp/code/category/arduinowiring/424. Shouldn't he have used one?

I also won't ever be turning on all LEDs at once. The largest number of LEDs on at any given time will be six. Am I correct to think I won't be needing any external components for the current drive, and just let Arduino supply all the power? Is there a risk of frying the Arduino if I do turn them all on by accident?

Thanks for all your help so far.

So did you read my tutorial on LEDs?

Am I correct to think I won't be needing any external components for the current drive,

No.

Is there a risk of frying the Arduino if I do turn them all on by accident?

No risk it is a certainty. Even turning one LED on with this scheam will damage your arduino.

Sadly there are a lot of bad / ignorant articles on the net, this is one of them. The absolute maximum current from an arduino pin is 40mA, it says so in the data sheet. Some people think that data sheets are a conspiracy, they are wrong. A reliable / repeatable design can only be made by running circuit elements at 80% or less of their maximum ratings. Please re read my LED tutorial.

I read your LED tutorial, and from what I understand, the external components I will need will serve to convert the Arduino's supplied current into appropriate values for feeding the LEDs. What I meant to ask in my previous question was if an external power source would be needed if I only plan on turning on a maximum of 6 LEDs at a time. My worry is more related to how I'd go about making the Arduino talk with this external power source, if it is needed at all.

Although I did read your tutorials, I'm sure you understand that for someone who's seeing a lot of these things for the first time, it's not as easy to connect the dots and abstract all this information into usable, concrete answers. In that sense, I really appreciate your willingness to teach beginners like myself.

I'm sure you understand that for someone who's seeing a lot of these things for the first time,

I do, but I also make demands on your power of thinking and welcome informed questions or clarification.

if an external power source would be needed

There is not enough power coming out of the arduino's pins. However the power supply of the arduino can supply some extra current. That is the 5V output on the board. You can take about 350mA from this without trouble, this is more than enough for a few LEDs. So the transistors would connect to the arduino (for control), to your LED, and to the 5V line.

If you need more then this 5V line is replaced by and external supply like a wall wart or battery eliminator. In that case you have to also connect the ground or negative terminal of this supply to the arduino's ground.

I do, but I also make demands on your power of thinking and welcome informed questions or clarification.

Hey, I can see where you got your name now ;D I may not meet your demands on power of thought, and I regret that. I really am trying my best, believe me.

There is not enough power coming out of the arduino's pins. However the power supply of the arduino can supply some extra current. That is the 5V output on the board. You can take about 350mA from this without trouble, this is more than enough for a few LEDs. So the transistors would connect to the arduino (for control), to your LED, and to the 5V line.

That really cleared up most of my doubts, thanks a lot!

I really am trying my best, believe me.

Don't worry, I do.

That really cleared up most of my doubts

See. :slight_smile: