Controlling Common Anode RBG LEDs w/ Arduino Mega

Hi, I'm planning a project that will involve 28*5 leds, 28 groups of 5 common anode rgb leds (each group of 5 LEDs strung in parallel, I think). I'm hoping to control them through pwm on an Arduino Mega.

I have very little experience with electronics, but programming should not be a problem. The problem is that I will need some way of handling the 84 leads from the LEDs at the same time. My original plan was to use a 4051 multiplexer to control the LEDs, but I had no luck when I tested it with just one LED. The combination of the multiplexer and the Arduino was too slow and I couldn't make tertiary colors (Or I did something wrong :-/).

From what I've gathered after digging around on the web, I'll need an external power source to power this many LEDs. I just read about MOSFETs, and I think that they might be one step in the right direction. I'll also need some way to accommodate these 84 pins. I'm not sure anymore about how to handle them since the multiplexer idea fell through.

Basically, I'm looking for opinions on how to approach controlling a large number of common anode rgb leds through pwm. I'd really like to stick with the Arduino Mega since the programming is so simple and I don't know what is used to program other microcontrollers.

Thanks in advance.

It's not going to be possible without adding extra hardware to the Arduino. At the very least, some transistors to handle the 100mA per color per LED group. And doing any brightness variation will be extremely processor intensive, if at all possible.

At this point I could just shamelessly point out my own products, intended to solve this problem. I think that I will. Anyone else is welcome to chime in, I think there are other shields etc that could be relevant.

ShiftBar:
This thing will connect to an Arduino using only 4 pins, and you can daisy chain as many modules as you need without using any more pins. It has three channels that can drive up to 150mA each, so one of these devices could control one of your 28 LED groups. This will allow 1024 different dimming levels on each LED channel.


MegaBrite:
Here's a module that already has the same brightness as your 5-LED groups. It's using red, green and blue LEDs that each contain 5 regular LED chips of the same color, 100mA forward current. It might not be exactly how you planned to construct your device, but maybe you're just looking for a certain amount of brightness output. Of course this module also daisy-chains with 6-pin cables and only requires four of your Arduino's I/O pins for the entire chain.

For any solution you eventually discover, you'll definitely need an external power supply. I find that MPJA has a good selection of supplies in various voltage and amperage ratings, and acceptable pricing.

Thanks for the quick reply!

After thinking it over, I'm going to simplify my project. It's just something I'm doing for fun, and I have no reason to give myself a headache about it.

You're right, the groups of 5 were just for brightness, it's really an arbitrary number. It's only important that there are 28 groups (or possibly 32). I'm going to switch to single color LEDs through digital pins instead. That way I'll be able to use 28 digital ins on the Mega and still have room to breathe.

The other part of my project consists of an infrared emitter and receiver in the center of each of the 28 groups. I should be able to power the emitters in a separate circuit and multiplex the receivers to the analog-ins since they only need to be read about once a second.

So, I guess now my question is simple: What do I need to do between the LEDs and the Arduino to handle the extra power from the power supply? Is that the right way to put it? Forgive my ignorance of electronics. I know the Arduino doesn't put out enough amps to light up all of those leds, so I'll need an external power supply. But, what else to I need? I know you talked about transistors in your post, but I'm confused in the role those would play.

In any case, it looks like this project just got a lot easier. :slight_smile:

You need the transistor to work as a switch witch provides more current.
The arduino open / closes the switch and the transistor provides the needed current.

Have a look here:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264573646

First off look at this:-
http://www.thebox.myzen.co.uk/Workshop/Motors_1.html
It's about motors and relays but it shows how a transistor can be used to switch a load.
Now 28 RGB LEDs is actually 28 * 3 = 84 separate LEDs and you don't have that many PWM outputs even on a Mega. Therefore what you need is some sort of external PWM LED driver.
Normally I would suggest the TLC9540 chip but these are on short supply at the moment and no one has any to sell.
There are a few other drive chips but this is a lot of external hardware to have. What sort of resolution do you need?

Have you run RGB LEDs and seen what colours they produce? I would advise looking at just one first (easily driven direct from the processor) before you make any decisions or purchases.

macegr's products might just be the way for you to go.

Thanks for the link. I've been busy with school and forgot to check back in on this post.

I'm not going to actually start building this project until summer. I'm just trying to learn and plan everything out, so getting my hands on a couple of those chips wouldn't be out of the question. Would they let me control multiple RGB LEDs simulaneously?

The LEDs aren't actually going to be in an array so I don't need any resolution. I have already played with a couple RGB LEDs and IR sensors, and got them working fine. I made a program through processing that allowed me to click anywhere on a color spectrum to change the color of the LED, similar to the color picker in a paint program.

I'll take a look at that transistor stuff. It seems like just learning about that is my next step.

I think I figured it out. I can daisy-chain six TLC5940 LED drivers, to control 32 RGB LEDs (common anode because the driver sinks current I believe :-?). Now I just need to figure out how to wire up my groups.

Below is a mock-up of half of the LED configuration. The blue dots are LEDs that are shared between groups. While there's 32 groups of 5 LEDs, there's really only 136 LEDs in total.

I've figured out how to wire this for single-color LEDs, but I'm not sure how to wire common anode RGB LEDs since they can't be in series. Or do I just get RGB LEDs with no common leads? Any suggestions?

Or do I just get RGB LEDs with no common leads?

You will be hard pushed to find that sort of component. I suspect that if one does exist it will only be in a surface mount package.

You will probably have to go for individual LEDs

I suspect that is one does exist it will only be in a surface mount package

Kingbright used to do a 6 pin DIL-packaged RGB LED, but it was a little awkward with a 2mm pin pitch instead of 2.54mm.

Maplin used to sell them, but don't appear to do so anymore.

Alright, thanks. I guess I'll have to make my own colors with three single-color LEDs.

Any ideas on how I would wire this up (with two pin LEDs)? Say the second row, for example. The middle group shares an LED with each side group. Any way I string them, I can't seem to avoid lighting up multiple groups at once.

Any ideas on how I would wire this up

Not sure what you are trying to achieve. If you are wiring two in series then unless those two belong to the same group you will never be able to avoid lighting up two groups at a time. This can't be what you are asking so what exactly do you want to do?

Well, I want all 5 LEDs of a group, wired in series, going to a sink pin in the LED driver. That's simple to do if all of the groups are isolated. I was trying to figure out a way to wire up the shared LEDs (the blue dots in the picture) so that they could be part of more than one group. I know it's not possible with the LEDs themselves, but I was hoping it could be achieved with diodes or something. Doesn't seem possible the more I think about it. I'll just have to isolate the groups and bump the LED count up to 480. X_X

The blue dots are part of two groups and so must respond to a command from one group OR another. So you need a logic OR function to drive these LEDs. So if you are driving each group with a high signal then take a diode off the two groups control signal (anode) and join the cathodes together, use this junction to power the single joint LED.