

Int potBlue = A2 // Potentiometer controls Blue pin -> A2 Int potGreen = A1 // Potentiometer controls Green pin -> A1 Int potRed = A0 // Potentiometer controls Red pin -> A0 Upload the following sketch to your Arduino board: /* Important: if you’re using an common cathode RGB LED, you need to connect the longer lead to GND instead of 5V. You can use the preceding links or go directly to /tools to find all the parts for your projects at the best price!įollow the next schematic diagram to wire the circuit:

RGB LED common anode or RGB LED common cathode.Arduino UNO – read Best Arduino Starter Kits.Note: we’ll be using a common anode LED for this project, but if you already have a common cathode LED it’s fine to use that just watch out for the differences noted in the circuit wiring and code. The project we’ll build uses three potentiometers to control the light intensity of each pin (LED) of the RGB LED to produce any color you want.įor this example you need the following parts:
#Arduino rgb led all colors how to
In this example, we show you how to control the color of an RGB LED using an Arduino. If the LED lights up with the black tip on the longest lead and the red tip on one of the other leads – you have a common cathode RGB LED.If the LED lights up with the red tip on the longest lead and the black on one of the other leads – you have a common anode RGB LED.So, to distinguish between common cathode and common anode RGB LEDs: On the other hand, if you have a common cathode RGB LED, you need to placed the black tip on the longest lead, and the red tip on one of the other leads (see figure below). If the LED lights up, this means you have a common anode LED. Then, place the black tip on one of the other leads. Place the red multimeter tip on the longest LED lead. Put you multimeter is in continuity mode. The best way to distinguish between a common cathode and common anode RGB LEDs is using a multimeter. Distinguish between RGB LED common anode and common cathode With the LED facing you so the anode or cathode (the longest lead) is second from the left, the leads should be in the following order: red, anode or cathode, green, and blue.

You can identify each lead by its length, as shown in the following figure. RGB LEDs have four leads-one for each LED and another for the common anode or cathode. This results in an LED that has 4 pins, one for each LED, and one common cathode or one common anode.

In a common anode RGB LED, the three LEDs share a positive connection (anode). In a common cathode RGB LED, all three LEDs share a negative connection (cathode). The figure below illustrates a common anode and a common cathode LED. There are two kinds of RGB LEDs: common anode LED and common cathode LED. This is the simplest color mixing chart, but gives you an idea how it works and how to produce different colors. To have an idea on how to combine the colors, take a look at the following chart. To adjust the intensity of each LED you can use a PWM signal.īecause the LEDs are very close to each other, our eyes see the result of the combination of colors, rather than the three colors individually. To produce other colors, you can combine the three colors in different intensities. For a white light, you’d set all three LEDs to the highest intensity. With an RGB LED you can, of course, produce red, green, and blue light, and by configuring the intensity of each LED, you can produce other colors as well.įor example, to produce purely blue light, you’d set the blue LED to the highest intensity and the green and red LEDs to the lowest intensity. An RGB LED is shown in the following figure: You can produce almost any color by combining those three colors. How is this possible with just one single LED? In this article you’ll learn:Īn RGB LED is a combination of 3 LEDs in just one package: With an RGB LED you can produce almost any color.
