How to connect Arduino Uno to 25 rgb leds?

Hi, i'm a newby with Arduino and i have a technical problem: i need to connect an Arduino Uno to 25 rgb leds but i don't know how.
I've read that should use a 3 - 8 decoder (is it right?), but if a single rgb led need 4 pins to work, how can i connect the other 24 in 11 pins?
And how can i change the color of a single rgb led?

Thank you everybody! And sorry for my bad english :slight_smile:

You need multiplexers. There are a number of ways to control multiple LEDs described on the Playground, under Output.

but if a single rgb led need 4 pins to work, how can i connect the other 24 in 11 pins?

One of those pins is ground, so you really only need three per LED. All the LEDs are connected to the same ground.

And how can i change the color of a single rgb led?

Paint?

There are many ways to do this.
Here is an example of 8 RGB LEDs. You may be able to expand on the LED numbers.

http://www.elcojacobs.com/using-shiftpwm-to-control-rgb-leds-with-arduino/

Thank you all for the answers! You were very fast :slight_smile:
I saw that i can use some multiplexers (PaulS) or a shift register (lightUp). Which one is the best solution? And how many multiplexers or shift register i need to light the 25 rgb leds?
Thank you so much! I hope my questions aren't so stupid! :wink:

25 RGB LEDs will have either:
25 anodes and 75 cathodes to control
or
25 cathodes and 75 anodes to control.

Which kind of LED do you have? That impacts how it can be done.

ShiftPWM can work with Common Anode or Common Cathode LEDS and you'd need 10 x 8 bit shift registers to do 25 RGB LEDs.

It'll involve a lot of resistors though.

Alternatively you can use ShiftPWM with constant current LED drivers, which means you don't need a resistor one every led output.

LED drivers are usually current sinking though, so you'd have to use Common Anode LEDs.

The TLC5940 may be a good device to use for this job. About $2.50 per piece on ebay from a US seller offering free shipping. - Scotty

Alternatively you can use ShiftPWM with constant current LED drivers, which means you don't need a resistor one every led output.

No you need a constant current drive at each LED output. If you think resistors are expensive at $0.01 to $0.001 I am not sure where you will find a constant current drive cheaper.
There are lots of solutions to this. The TLC5940 will give you 16 outputs so for 25 RGB LEDs you need (25 * 3) / 16 = 5 chips.
The TLC5947 gives you 24 outputs so you only need 4 chips and they are easier to drive.
The humble shift register gives 8 outputs so you need 10 of them for your project.
The PCA9685 is the easiest to drive as it is an I2C device again 16 outputs per chip so 5 chips but you need a resistor on each colour with this and a common anode RGB LED.

Thank you again for the answers!
So, i think i will use common anode rgb led.
I'm looking for the TLC5940 and others but i can't find them in my store. I only found the Shift Register 8-Bit (74HC595) and the Shift Register 8-Bit High-Power (TPIC6B595).
I'm reading this article http://www.elcojacobs.com/using-shiftpwm-to-control-rgb-leds-with-arduino/
If i use 10x 74HC595 i will need (per every rgb led): 1x 150ohm resistor (red) and 2x 100ohm resistor (green and red). Is it right?
I also read that with many shift register, my project could become slow (?)

I will post the schematic that i'm trying to make for my project :wink:

Thanks everybody! You are great!

Grumpy_Mike:

Alternatively you can use ShiftPWM with constant current LED drivers, which means you don't need a resistor one every led output.

No you need a constant current drive at each LED output. If you think resistors are expensive at $0.01 to $0.001 I am not sure where you will find a constant current drive cheaper.

I don't believe I made any reference or implication that it would be a cheaper way of doing it did I? Not sure why you felt the need to pick that up and imply that I was trying to say something that I wasn't.

No-one uses constant current drivers because it's cheaper than using an alternative, like SR, with resistors. It's done because it's more convenient than soldering bucket loads of resistors, and it's a more consistent way to drive them.

1x 150ohm resistor (red) and 2x 100ohm resistor (green and red). Is it right?

You mean
(green and red blue).

Yes it sounds typical of the resistors you need for about 20mA per LED. I am making a project at the moment that uses some and I have settled on 91R for the green and blue instead of 100R but it sounds fine.

I also read that with many shift register, my project could become slow

It depends on what you need to do. As you haven't said what your project is it is hard to say. However, altering the brightness using shift registers is CPU intensive.

Thank you :wink: My project is a 25 rgb leds single color changer with a random function.
I tried to build a scheme (based on this http://www.elcojacobs.com/wp-content/uploads/2012/08/shiftpwm_74hc595_RGB.png). Practically the 74HC595 shift works with a "data" connection (in 1st pin, out last pin), but in the code how can i control the single led?
I attached the scheme i build (only two shifts), but i think the "shift" has less pin that it should have.

Thank you for the big help!

Why not take a look at WS2803?
Each can drive 6 RGB LEDs, and they are designed to be daisychained.

http://www.ebay.com/itm/5x-Worldsemi-WS2803SO-18-Channel-RGB-Constant-Current-LED-Driver-SOP-WS2803-PWM-/150721605686?pt=LH_DefaultDomain_0&hash=item2317b53036

WS2803-preliminary-En.pdf (437 KB)

I too am seeking to graduate from controlling several single color LED's to controlling
more than 16 RGB LED's using TLC5940's. But i'm now realizing, the 74HC595 appears to be an interesting choice as well.

Thanks all!

many options, more studying to do.

"more than 16 RGB LEDs" implies more than 48 LED pins to control, unique anodes/cathode, and 16 common cathodes/common anodes.
HC595 has 8 pins.
Are you planning on 6+ 595s, or some kind of multiplexing scheme?

but in the code how can i control the single led?

Simply by setting or clearing a single bit in the data.
Each bit controls one LED.
On the arduino this is easy with the bit set and clear instructions.

@CrossRoads:

yes. I want to multiplex and take advantage of the 3 TLC5940's at my disposal, would prefer to use it with its 16 outputs rather than the 74HC595.

But now… distracted by the ShiftPWM library.

Hmmm....

Hello, thanks again! I ordered the shift registers and the Common anode rgb leds, so in a few days i will begin my project! :wink:
@ grumpy_mike, i saw the arduino clear bit but i can't understand hit it works, can you please make an example? Is it right my scheme i uploaded?

Thank you for the help!!!

When you send stuff to a shift register with shiftOut you send a variable containing a number. This is held in the computer as a binary number. To turn all the LEDs off you might set this number to zero.
To turn only the last LED in the shift register on the number you send hasto have a logic one in the lastbinary bit position in the word. So to do this you can use the set bit for bit seven instruction on the variable that was previously zero.
Look up the syntax of this instruction in the referance section.