So we've talked a lot about LEDs and like how does an LED work on a semiconductor level.
We've talked about some of the pros and cons of the LEDs.
And we've also talked about how an individual LED can be dimmed
whether through PWM or through analog current control.
So, we've discussed all of these things before but now we want to talk about RGB LEDs
and how to use them to produce different colors.
An RGB LED is basically an LED package that can produce almost any color.
This is great because it can be used in a lot of different applications such as
outdoor decoration lighting, stage lighting designs (and) home decoration lighting.
LED display matri- matrices. They're really cool.
So you can use them in a lot of different ways.
RGB LED literally stands for Red Green Blue.
The way you get all of these different colors is by making either the red, the green, the blue,
brighter or dimmer (or) however you need to get the exact color you want.
In my mind I think of like, when I'm looking over the design guys' shoulders
and I see on their screen there's this wheel and it just shows
all the rainbow of the color in different areas and then they just kind of choose
what they want from that to get the color they want.
You can do the exact same thing with an RGB color.
Only thing you need to do with this RGB LED is to set the intensity of each leg
to combine them together to get the color output that you want.
In this case, we're using pulse width modulation to adjust that intensity
individually and the trick here is that our eyes will see that combination of colors
instead of the individual colors because the LEDs are very close to each other inside.
When I say the LEDs that's the funny thing. So an RGB LED is actually simply three LEDs
that share either common cathode or common anode.
As you can see here, there are four leads and one goes to the red LED,
one goes to the green, one goes to the blue and then
in this particular one, it's a common cathode.
If you look inside, you can see that the longest lead is actually connected
to the base there, it's the biggest piece of the structure inside so literally
an RGB LED is three LEDs stuck together in one particular package.
And that makes it really easy because then you don't have to put three LEDs together
and hope that that's good enough and it makes it a little bit more space-saving and
having a common cathode or anode if you get one of those is really really helpful.
Briefly, the difference between a common anode vs. a common cathode
is that in a common anode, the anode pin of the internal LED
are all connected to the external anode pin which I don't have an example of that here
but to control each color, you need to apply a low signal or ground
to the red, green and blue pins and then connect the anode pin to the
positive terminal of the power supply 3 volts, 5 volts or whatever.
In this case with a common cathode, you have the cathode pin of the internal LEDs
are all connected to a single pin and so to control each color,
you need to supply a high signal, Vcc or VDD to the red, green and blue pins
and then connect the anode pin to the negative terminal of the power supply.
And that is actually what I have here. So let's look at this really quick.
This is my demonstration. All of this, the way it's set up and the code on the Arduino
is on our website and JB put this tutorial together so thank you very much JB.
What I have going on right here is, I have some potentiometers, some trimmers right here
that are sending a signal, basically an analog signal, to the ADC of my Arduino.
And the ADC is measuring that voltage and then based on that, on the voltage
that i'm giving it, it's changing the duty cycle of the pulse width modulated signal to the RGB LED.
I actually went one of the few things I've done right in my life.
I have done the red, green and blue to control each one of these colors
and that's also associated over here with the trimmers.
This being cathode, it is going to be positive voltage right here to the red, green and blue.
And then your common cathode right there, that is going to ground.
So I'm just going to show how this is done really quick.
You can go over to the red and very easily change it and you get red.
Very nice!
Change that over to green and then blue.
Now this is pretty straightforward where it gets complicated and gets interesting
is that you can make combinations, again colors are not my strong points
so as I was messing with this, I'm sure my kids in elementary school know this
but I had forgotten red and green make yellow.
So you can change the green if you want it to be a little bit more red
get a bit more of a sunset glow there and maybe even throw in a bit of blue
I don't know what's gonna happen. That's kind of violet.
But as you adjust these, you get basically whatever color you want.
So we can turn off the red completely and pull it up and get a greenish blue color
right there and again it's one of those things where it's however you need to change it
to get the color you want and when you set this up and you're getting those values
and deciding what you need to do, make sure that you take into account
the different resistors you have here so I'm basically doing a big no-no
right here and all of my resistors are the same even though
the red has a much smaller forward voltage drop than the blue and the green.
So when you are calculating out what the duty cycle is to get the
exact colors you need, make sure that you're also taking into account
the resistor value right there or else you're not gonna get the same brightness
and you're not going to get the same shade you need.
So not only the duty cycle is taken into account here, of the pulse width modulation,
but also the resistor values that you have on each one of these pins.
And although I am controlling this specifically with the trimmers,
it's something where if you know exactly the colors you want,
you can go and see alright I know that I need to have 20% duty cycle
on this 70% duty cycle on this and maybe 100% duty cycle on that
to get the color I want and then you can just hard code that into your Arduino
or into whatever logic board you have and it will produce the color you need.
So, RGBs are really simple. I mean all it is, is 3 LEDs that share
a common cathode or a common anode. They're very simple.
The code as you'll see on our website for this Arduino is very simple to do
even this where you can control it. They're fantastic to use and whatever
project you want to do again whether that's some small little cube that you're
gonna put on your desk or you're doing some cool lighting in your house.
They're fun to use, they're easy and they're really cheap.
I mean it's crazy how cheap LEDs have gotten so highly recommend on your
next project putting something in there where you can make it
a little bit brighter, shinier and get exactly what you want.
Hope you found this interesting and useful.
If you did, leave us a like and subscribe to our channel.
We'll catch you next time.