RGB LED with potentiometer – Arduino tutorial

Incandescent light bulbs are slowly becoming a thing of the past with LEDs kicking in, especially RGB LEDs. So, why not learn how to control your RGB LEDs the way you want? In this tutorial we’ll be setting our RGB LED to any color we want with the help of a potentiometer. Let’s go!

List of things you’ll need:

  • Arduino Uno
  • Breadboard wires
  • Potentiometer
  • RGB LED
  • 3x 220 Ohm resistors
  • USB-B cable (or something else to power your Arduino)

Once you’ve got all of them, connect them like this:

Like with every LED, we need a resistor to keep it from frying. You’re going to need 3 in this case for each color (red, green and blue).

Once that’s done, connect your Arduino to your PC and upload this sketch below.

To do what you require you will need to crossfade between red, green and blue. At zero potentiometer setting red is fully on. Green and blue are off. As you adjust the potentiometer over the first 1/6th the green fades up to 100%. On the next 1/6th the red fades out until you only have green. The pattern repeats for green to blue transition and finally for blue to red ending at the start point of full red.

You can see in the code above how we managed to do it with this theory.

One Comment

  1. jeff

    25 Aug 2018 15:59:07

    What RGB diode is used ?
    Common Anode or common cathode?
    The schematic shows one RGB diode lead ( (the one on the left )connected to Ground
    however Google shows the common lead is not the first lead on the left as common but the second lead.

    Also there is no mention of resistor values.

    All in all something less that professional work

    please comment

Leave a Comment

Stay tuned:

* we promise that we won´t spam you, never.