top of page

How to use RGB LED with Arduino



Are you looking for an exciting project that combines electronics, coding, and lighting? If so, then RGB LED and Arduino are the perfect combination!


Content


Concept

LED stands for "Light Emitting Diode," which is a semiconductor device that emits light when an electric current passes through it.


LEDs are commonly used in a variety of applications, including lighting, displays, indicators, and more. Unlike traditional incandescent or fluorescent bulbs, LEDs are more energy-efficient, durable, and versatile.

An RGB LED (Red-Green-Blue Light Emitting Diode) is a multi-colored light source consisting of three individual LEDs that emit red, green, and blue light. By combining these three colors in various proportions, different colors can be made such as yellow, purple and white. These LEDs are used in many applications to add color, such as lighting up buildings or creating decorative displays.


Required Components

  • Arduino UNO

  • RGB LED

  • 3x 220 Ohm Resistors

  • Breadboard

  • Jumper Wires

Buy Arduino Super Starter Kit from Amazon

Wiring

Arduino UNO

RGB LED

GND

GND

GPIO 11

Red Pin

GPIO 10

Green Pin

GPIO 9

Blue Pin

RGN LED to Arduino UNO Wiring




Related Video


Arduino Code

#define red_pin 7
#define green_pin 6
#define blue_pin 5

//unsigned long rgb = 0xFF0000; // Color in Hex
//unsigned long rgb = 0x00FF00; // Color in Hex
//unsigned long rgb = 0x0000FF; // Color in Hex
//unsigned long rgb = 0x66CC33; // Color in Hex
unsigned long rgb = 0xCC0066; // Color in Hex

void setup()
{
  pinMode(red_pin, OUTPUT);
  pinMode(green_pin, OUTPUT);
  pinMode(blue_pin, OUTPUT);

  analogWrite(red_pin, rgb >> 16);
  analogWrite(green_pin, (rgb & 0x00FF00) >> 8);
  analogWrite(blue_pin, rgb & 0x0000FF);
}

void loop()
{
}
28 views

Comments


bottom of page