# Help Needed_ Interfacing 5 RGB Leds using minimum microcontroller Pins

#### mishra87

Joined Jan 17, 2016
865
Hello All,

I want to interface 5-RGB using minimum MCU pins. Means I have total 15 leds to interface.

So could anybody suggest me any solutions or approach to do this.

#### BobTPH

Joined Jun 5, 2013
2,745
Use WS2812B LEDs. All are controlled by one pin.

Bob

#### DickCappels

Joined Aug 21, 2008
6,806
What LEDs in terms of amps, volts?

#### mishra87

Joined Jan 17, 2016
865
What LEDs in terms of amps, volts?
Vdd = 5V ,
Vf_Led = 2V
If = 5 mA

Thanks !!!

#### mishra87

Joined Jan 17, 2016
865
Use WS2812B LEDs. All are controlled by one pin.

Bob
I am talking about 5 RGB Leds .
1 RGB means - 1 Red , 1 - Green , 1 - blue

So total 15 Leds

And 5 Leds can be turned ON at a time.

#### djsfantasi

Joined Apr 11, 2010
7,229
What MCU are you using and what else is it doing?

Brute force multiplexing could reduce the needed pins almost in half. 8 pins instead of 15.

With additional circuitry, you could cut 5 of those pins to 3 bit it hardly seems worth it.

With an external shift register, you could get it down to two or three pins.

There are many options. But we need to know what these five RGB LEDs are used for, what the MCU is doing and what other resources and/or restrictions you have.

#### DickCappels

Joined Aug 21, 2008
6,806
Vdd = 5V ,
Vf_Led = 2V
If = 5 mA

Thanks !!!
Do the R, G, and B LEDs all have a common anode or cathode, or are there six leads to the package?

A link to the datasheet would probably be helpful at this point.

#### be80be

Joined Jul 5, 2008
2,049
kind of hard to Charlieplex RGB leds seeing they have common anode or cathode.
Now if its 3 leds then it's doable

#### jpanhalt

Joined Jan 18, 2008
10,962
For common cathode: https://forum.43oh.com/topic/1718-controlling-4-rgb-leds-with-minimal-components/?page=2

I think the bigger problem will be to have them all on at the same time. Rapid on/off cycles could give that appearance. My comment was not meant so much as a solution but to round out djsfantasi's list, and most important, to give the TS some background reading. If the TS is pin limited, then he/she may want to consider other solutions or redefine the criteria.

#### djsfantasi

Joined Apr 11, 2010
7,229
For common cathode: https://forum.43oh.com/topic/1718-controlling-4-rgb-leds-with-minimal-components/?page=2

I think the bigger problem will be to have them all on at the same time. Rapid on/off cycles could give that appearance. My comment was not meant so much as a solution but to round out djsfantasi's list, and most important, to give the TS some background reading. If the TS is pin limited, then he/she may want to consider other solutions or redefine the criteria.
Depends on what the LEDs are being used for. Without that information. I’m leaning towards the shift register solution. One clock pin and one data pin may be all that is required. Depending on the particular shift register, you may need a latch pin.

Using shift registers, the LEDs will always be on except for a brief period when an LED changes state. That period won’t make a perceptible change in the output.

Using shift registers, at a small cost in processing time, the solution can be expanded to many LEDs. For this application, you only need two 8-bit registers, like the 74HC595

#### BobTPH

Joined Jun 5, 2013
2,745
I am talking about 5 RGB Leds .
1 RGB means - 1 Red , 1 - Green , 1 - blue

So total 15 Leds

And 5 Leds can be turned ON at a time.
I understand that. The WS2812 is an RGB LED that contains a chip to control it on the same die.

You can control 1 or 5 or 500 of them with a single signal.

You asked how you can control 5 RGB LEDs with a minimum of pins. And I gave you the answer. Unless someone comes up with a solution that uses no pins, this is the best answer.

Bob

Joined Feb 20, 2016
3,657
I too add a vote for the WS2812 solution.
Nothing else to add, and full colour and brightness control, all on one pin.
Plenty of example on the Internet showing how to drive them.

#### djsfantasi

Joined Apr 11, 2010
7,229
Sometimes we get caught up in the question (with its concomitant assumptions) rather than an appropriate answer.

I also vote for the WS2812 solution.

Joined Mar 10, 2018
4,057
Are you concerned about package size, eg. # I/O available in smallest
package ? If so what technology packages can you handle ? Can you
handle BGA, WLCSP .....?

How many GPIO do you need besides the LED drive GPIO ?

Regards, Dana.