RGB LED: everything you need to know about this component

LED RGB

There are many types of semiconductor diodes on the market, and within them there is a particular type such as LEDs (Light-Emitting Diode). These types can emit light, but not all of them are identical. Manufacturers play with different compositions of the semiconductor material so that they emit lights of different colours. In addition, there is the RGB LED, which uses various combinations of LEDs to emit light in different colors.

Therefore, if you want to create a project in which a single color LED is not enough, with RGB LEDs you can achieve wonderful multicolor light effects. And they are not very different from conventional LEDs, so you can integrate them with your Arduino board or other electronic projects in a very simple way.


RGB

RGB light spectrum

RGB (Red Green Blue) represents the colors red, green and blue. It is a very typical color composition that you will have heard many times in the world of electronics. In addition, you should know that with only these three colors can form many other colors, as they are the primary. That is why printer cartridges and toners are made of cyan, magenta and yellow (CMYK), and by mixing them with black, many other tones and different colors can be achieved.

In the case of the LED light, something similar happens, being able to use different lights from those three primary colors to get many other combinations that go beyond the monochrome of the traditional LEDs. In fact, many types of screens and electronic devices use this combination to display images.

The RGB LED

LED RGB pines

The RGB LED is a special type of LED diode that consists of several simple LED arrays like those found in other single-colour LEDs. Thus, they can emit in these three primary colors, generating all kinds of effects and different colors (even white by combining red, green and blue at the same time) by just controlling one of the pins of these components.

The 3 LEDs packed in one package are capable of producing this whole range of colours. It has a slightly different pinout than conventional LEDs, as it includes 3 pins, one for each colour (cathode or +) and an additional common pin, the anode (-). Otherwise it doesn’t have too much mystery…

Colors and semiconductor materials

What is interesting for you to know is that thanks to the semiconductor type you can get different colors. This is what differentiates red LEDs from green, yellow, blue, and other tones. Researchers have been combining different materials to achieve all the colors that currently exist on the market. For example:

  • IR: Infrared LEDs use GaAs or AlGaAs as materials to emit at this IR wavelength.
  • Red: Red light LEDs use AlGaAs, GaAsP, AlGaInP and GaP.
  • Orange: semiconductor materials are used as GaAsP, AlGaInP, GaP with some variations.
  • Yellow: it can be a composition similar to the previous one, like GaAsP, AlGaInP and GaP to emit in a wavelength of the electromagnetic spectrum corresponding to the yellow.
  • Green: to emit at this wavelength, special materials are needed such as GaP, AlGaInP, AlGaP, InGaN / GaN.
  • Blue: in this case semiconductors and dopants based on materials such as ZnSe, InGaN, SiC, etc. are used.
  • Violet: it is created from InGaN.
  • Purple: Dual blue and red LEDs are used to achieve this color. Even plastic of this color with internal white LED light is used to give this effect.
  • Pink: there is no material for this color, what is done is to combine two LEDs of different colors to get this color, like red with yellow, etc.
  • White: this is what has given rise to the current LED bulbs, with pure white or warm white colors. For this purpose, blue or UV LEDs with yellow phosphorus for pure white, or orange phosphorus for warm white are used.
  • UV: the ultraviolet spectrum can be achieved with various materials such as InGaN, Diamond, BN, AlN, AlGaN, AlGaInN.

Integration with Arduino

 

Arduino with RGB LED

If you want to use the RGB LED with Arduino, you can start by creating the above picture scheme. It’s very simple, just use the RGB LED and an anode resistor as you do with the LEDs, and connect it to the digital pins of your Arduino board. The connection should be as follows:

  • Long pin: the longest pin of the RGB LED must be connected to Arduino’s GND pin, as it is the one marked as -, and is the common anode. This is where the 330 ohm resistor will be connected between the diode pin and the Arduino board.
  • Red: This is the single pin on the other side of the long pin. You can connect this to any pin you want.
  • Green: This is the one right next to the long one, but opposite the red one. You can also connect it to any Arduino digital pin.
  • Blue: it is the one next to the green one, on the opposite side of the red one. Do the same with it so you can control it from an Arduino output.

Although you can use whatever pins you want, it’s better to use the PWM so you can play with the signal…

After this basic connection, you can start with the programming of the sketch taking into account the pins in which you have connected each pin. In the Arduino IDE you can generate a small source code that you can load to your Arduino board to start testing how the RGB LED works:

void setup()
   {
       for (int i =9 ; i<12 ; i++)
            pinMode(i, OUTPUT);
   }

void Color(int R, int G, int B)
    {
        analogWrite(9 , R); // Red
        analogWrite(10, G); // Green
        analogWrite(11, B); // Blue
    }

void loop()
   { Color(255 ,0 ,0);
        delay(1000);
        Color(0,255 ,0);
        delay(1000);
        Color(0,0,255);
        delay(1000);
        Color(0,0,0);
        delay(1000);
   }

With this simple code you will see that first it turns on in red, then it turns on in green, then in blue, then it turns off and then it would start the loop again. Each light remains for 1 second (1000ms). You can alter the order, the times, and the values inside the brackets to get more colors by combining them. For example:

  • The first value corresponds to red and you can vary it from 0 to 255, being 0 no red and 255 the maximum.
  • The second value corresponds to green, with values of 0-255 as above.
  • The third one is for blue, the same as the previous ones.

To help you get other specific colors, you can use this website. An app will appear where you can choose the colour range you want by moving the cursor of the colours to where you need it. Look at the values of R, G and B, if you replicate them in your Arduino IDE program you will be able to create the color you want just like you do in this web or in programs like Paint, Pinta, GIMP, etc. For example, to get a striking green, you can use the values 100,229,25.

Eye-catching green RGB

For more information about using Arduino IDE or programming, you can download our free PDF course.

Leave a Comment

*

*