### Author Topic: RGB LED  (Read 1797 times)

0 Members and 1 Guest are viewing this topic.

#### NivagSwerdna

• Super Contributor
• Posts: 1865
• Country:
##### RGB LED
« on: May 06, 2016, 11:08:27 am »
This is a very newbie question...

I have a RGB LED purchased from EBAY (actually I bought a few...), it has no data sheet or spec other than it is a RGB LED

The LED has 4 wires all different lengths, the longest wire being common and the others being R,G and B.

I would like to drive the LED from a microcontroller pin in such a way that it shows R, G and R+G.

My issue is that G seems much brighter than R and in particular R+G looks G rather than Y.

Applying Ground to the common pin...

With a constant current limited supply 4mA of R, but only a fraction of a 1mA is required for G is required for readable levels

So for 5V from my microcontroller pin... 1k on R and 8k on G?  These seem like very big numbers? Does that sound right?

• Super Contributor
• Posts: 1875
• Country:
• Reactor Operator SSN-583, Retired EE
##### Re: RGB LED
« Reply #1 on: May 06, 2016, 11:21:14 am »
Rled = (Vdd - Vledthreshold - Voutpinlow) / Iled

So if Vledthreshold =~ 1.5, Voutpinlow = ~.4, Vdd = 5,
you can compute what you will get.

Note Y, R, G thresholds all different.

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer

#### NivagSwerdna

• Super Contributor
• Posts: 1865
• Country:
##### Re: RGB LED
« Reply #2 on: May 06, 2016, 11:39:23 am »
Thanks for that.

It seems that the R never seems to get hugely bright, so if I aim to get the R running at 10mA and then get the G running at same brightness around 1mA...

... my colour vision is unfortunately not perfect (!) but to me it seems that at low currents the G LED looks very yellow and only greens up at higher currents (at which it far outpaces the R)...

Maybe it's me with the issue!

#### sokoloff

• Super Contributor
• Posts: 1392
• Country:
##### Re: RGB LED
« Reply #3 on: May 06, 2016, 12:15:49 pm »
With a microcontroller, you can use pulse-width modulation (PWM) to vary the brightness as well.

This lets you run higher currents for a percentage of the time. Imagine a square wave with a 5% on-cycle vs a square wave with a 50% on-cycle. The second will be much brighter visually, of course.

This also lets you pick resistors [possibly none] that give you full brightness on the LED and then it's a simple matter of software to change the intensity, meaning you can upgrade as fast as you can compile and download rather than rewiring the breadboard or reworking a PCB, and is much less sensitive to parts variations/tolerances/temperature.

IMO, this is a much better solution than Ohm's lawing your way to get the color balance you want based on the random LED you have in your hand.

• Super Contributor
• Posts: 1875
• Country:
• Reactor Operator SSN-583, Retired EE
##### Re: RGB LED
« Reply #4 on: May 06, 2016, 01:45:11 pm »
In this application if trying to run LED directly from UP w/o using
current limiting R you have to be aware of a couple of issues -

1) The UP has a max current / pin spec that you cannot exceed.
You cannot rely on PWM to control that, has to be an R or some
other kind of current limited LED drive, like a current source.

2) The UP has a limit on internal port or buss current limit you
cannot exceed, again only R to limit current supports that. If
you exceed the current you could get internal logic operation
failure.

3) Use of a PWM + Rlimits perfectly acceptable. Note PWM at
100% duty cycle, which is 100% brightness, in this case effectively
out of the circuit, and R establishes the curretn for max brightness.

4) Use of a PWM (with a light sensor) can serve an important function,
control of brightness with ambient light, therefore saving power con-
sumption in a low light environment.

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer

#### Jeroen3

• Super Contributor
• Posts: 3392
• Country:
• Embedded Engineer
##### Re: RGB LED
« Reply #5 on: May 06, 2016, 07:10:13 pm »
The human eye has a nonlinear percieved brightness. Which also changes depending on the color.
Also, some led colors can be made more efficiently.

#### stmdude

• Frequent Contributor
• Posts: 479
• Country:
##### Re: RGB LED
« Reply #6 on: May 06, 2016, 07:15:05 pm »
The human eye has a nonlinear percieved brightness. Which also changes depending on the color.

Yup. In the RGB context, the eye is about as sensitive to R & B, but about twice as sensitive to G, as compared to R&B.

#### Audioguru

• Super Contributor
• Posts: 1508
• Country:
##### Re: RGB LED
« Reply #7 on: May 07, 2016, 01:13:25 pm »
Old green LEDs were about 2.2V and were not bright. New LEDs are made with the same material as blue LEDs, are about 3V and are very bright.
I agree that our vision is more sensitive to green than to red.

Smf