# Electronic components: RGB LEDs

> Learn how an RGB LED mixes red, green, and blue from its four leads, the difference between common anode and common cathode, and how to test which you have.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2021-03-11 | Topics: [Arduino](https://flaviocopes.com/tags/electronics/) | Canonical: https://flaviocopes.com/electronics-components-rgb-leds/

An RGB LED is a special kind of LED that looks like a regular LED, but it has 4 leads and it can display a different color based on the configuration.

![Two RGB LEDs with four metal leads each showing the characteristic 4-pin configuration](https://flaviocopes.com/images/electronics-components-rgb-leds/IMG_3150.jpg)

We talked about LEDs previously. Normal LEDs typically have one color, which can usually be red, blue, green, yellow, white, and it has 2 leads:

![Single blue LED with two leads on wooden surface showing typical LED structure](https://flaviocopes.com/images/electronics-components-rgb-leds/IMG_2860.jpeg)

An RGB LED is like 3 LEDs into one, but it's even more, because it can create any color from those 3 primary colors, by providing different amounts of current to each lead. Just search "mixing primary colors" on Google for more information on this.

The 4 leads are one for each primary color, **red**, **blue**, **green**, and then one common pin.

There are 2 kinds of RGB LEDs: **common anode** and **common cathode**.

> Remember, LEDs are diodes, so the direction of the current is important

In a common cathode configuration, the common pin is the ground.

In a common anode configuration, the common pin is `Vcc`, the positive voltage.

This is very important for how we build our circuits. Remember that LEDs need to be connected to a resistor to limit the current.

How do you find out, if you don't now which type of RGB LED do you have? The easiest way is to test it.

Connect the RGB LED to a breadboard:

![White breadboard with numbered holes showing the connection points for electronic components](https://flaviocopes.com/images/electronics-components-rgb-leds/IMG_3151.jpg)

![RGB LED inserted into breadboard with four leads positioned in separate rows](https://flaviocopes.com/images/electronics-components-rgb-leds/IMG_3155.jpg)

Now connect the longest pin to ground and a pin to `+` through a resistor. I used a 1kΩ resistor in this example:

![RGB LED on breadboard connected to resistor with black and red jumper wires](https://flaviocopes.com/images/electronics-components-rgb-leds/IMG_3159.jpg)

Now connect a battery, a 9V battery for example, and see if it lights up:

![RGB LED circuit connected to 9V battery showing bright blue light output](https://flaviocopes.com/images/electronics-components-rgb-leds/IMG_3160.jpg)

Great! Now you can change the color of the LED by connecting the other 3 pins with resistors of different resistance values:

![RGB LED on breadboard with multiple resistors showing yellow-orange light output](https://flaviocopes.com/images/electronics-components-rgb-leds/IMG_3164.jpg)

![RGB LED circuit displaying bright cyan blue light with resistors on breadboard](https://flaviocopes.com/images/electronics-components-rgb-leds/IMG_3162.jpg)

![RGB LED showing purple-blue light with three resistors connected to different leads](https://flaviocopes.com/images/electronics-components-rgb-leds/IMG_3165.jpg)
