5 RGB LED array - Newbie question

Hi, I can't seem to find an answer to my basic question since most tutorial cover either 1 rgb (for color mixing) or a Matrix of many LEDs. I was just wondering if I could manage controlling 4 or 5 common CATHODE RGB leds simply with an arduino. ie using the 5V from Arduino and appropriate resistor for each color, Could I run all 5xR, 5xG and 5xB together and get the full 5V from 3 PWM pins? OR do I absolutely need a Transistor, relay, etc on a separate circuit with 9 or 12V power source? How would you guys set this up in the most simple manner.

Note: my final goal is to use ardumote or touchOSC to control the color of the Array. Everything could be plugged with a wall wart so no worries on current draining batteries too quickly.


You can only source or sink 40 mA from any one Arduino pin. Typically that would mean two LED's, max, per pin. To drive the cathode of a common-cathode RGB LED you will need a transistor to sink the power. If you are multiplexing the LED's and only light one at a time you can connect all 5 anodes to one pin. Since only one cathode is grounded at a time, power will only be drawn by one LED at a time. The Arduino can handle that.

With only 3 PWM pins, you can multiplex led connecting 5 Red anodes to 1 PWM pin, 5 Green to second PWM, and 5 Blue to third one PWM pin. Cathodes goes to 5 digital pin. Than in your code you select LED to light up by changing it's pin output to LOW, the same time all others 4 digital pin switching to HIGH. Here is example, :

//PWM pins 9 - red, 10 - green, 11 - blue;
//digital pins 2 - first led, 3 - second, 4 ...., 5, 6.
  digitalWrite(2, HIGH);     //LED switch - OFF
  digitalWrite(3, HIGH);     //LED switch - OFF
  digitalWrite(4, HIGH);     //LED switch - OFF
  digitalWrite(5, HIGH);     //LED switch - OFF
  digitalWrite(6, LOW);     // LED switch - ON   

  analogWrite (9,   R5_value);   //color mixture for led 5
  analogWrite (10, G5_value);   
  analogWrite (11, B5_value);

Don't forget resistors, 3 in series with PWM pins.

thanks for your replies, So I cannot have all 5 light up at the same time then?

I have a bunch of 2N2222 transistors, could I make it happen? Where can I find a basic schematic for doing that? thanks

So I cannot have all 5 light up at the same time then?

No, you can't. To light up all 5 you need 15 PWM pins. Transistors wouldn't change anything. In example code posted above, LEDs should be switch very fast, and because perception of vision effect, you will see like all of the leds lighted the same time. Other option TLC5940, search for example code, chip very popular among hobbyst.

Thanks Magician, good idea except it says When using with RGB LEDs get LEDs with common anode. Common cathode will not work properly.
But that would be the kind of solution I need I guess.
Any other ideas using common cathode leds?

Hold On, I justed flashed on something johnwasser says. You can only source or sink 40 mA from any one Arduino pin. Which mean I could manage having 4 RGB LEDs in total? 2 series and 2 parrallel, and take all 6 PWM pins? My only problem remaining would be the cummulative 6.4V needed for the B and G Leds? Does this make any sense or am I completely off here? thanks

I think you are off. Look here: http://arduino.cc/playground/Main/InterfacingWithHardware#Output for 7 segments driver, there is an arduino library, 4 digits x 7 segment (= 28 leds total ) w/o peripheral hardware except resistors.

5 RGB LEDs is 15 LEDs. Of course you can PWM 15 LEDs if you do it right. Have a look at my experiments http://blog.blinkenlight.net/, especially http://blog.blinkenlight.net/experiments/removing-flicker/glowing-bounce/ for examples on how to do this. The experiments are not yet at the limit of what can be done. I aim to push this further :wink:

Which mean I could manage having 4 RGB LEDs in total? 2 series and 2 parrallel,

Try and draw the schematic, you can’t have RGB LEDs in series.

OK let's start over. I just ordered a TLC5940 to expand the PWM pins I would need. I'm guessing this is the simplest option for my purpose. I will be looking into how to wire this chip into my circuit when I get it in the next couple days. Could anyone tell me if I need any other component to make this work? Will it be as simple as hooking up the Serial input pin of the chip to the arduino and having access to the 16 PWM pins of the chip in the same manner as I normally would with arduino pins? ie a bunch of resistors and that's it?

First thing to get when using TLC5940 and the likes are common ANODE rgb leds. The other kind are quite useless for these drivers.

I know, I'm pretty disappointed to have bought a bunch of common cathodes. Why does every project imply 10 trips to the store ?!