Skip to content

1.5.0 RGB Introduction

The RGB LED module is a versatile component that allows you to display a wide spectrum of colors by combining three primary light colors: Red, Green, and Blue. Unlike a standard single-color LED, an RGB LED is essentially three separate LEDs housed in a single package.


Additive Color Mixing

An RGB LED operates on the principle of additive color mixing (the same technology used in computer screens, televisions, and phone displays). By mixing different intensities of Red, Green, and Blue light, you can create virtually any color:

  • Red + Green = Yellow
  • Green + Blue = Cyan
  • Red + Blue = Magenta
  • Red + Green + Blue = White
  • All channels off = Black (No light)

By adjusting the brightness of each channel using Pulse Width Modulation (PWM), you can produce thousands of custom shades (e.g., orange, purple, pink).


Pin Configuration and Types

An RGB LED module has four pins: 1. R (Red): Controls the red LED channel. 2. G (Green): Controls the green LED channel. 3. B (Blue): Controls the blue LED channel. 4. Common: The shared return path, which determines the type of RGB LED.

There are two main configurations for RGB LEDs:

Type Common Pin Connection Logic to Turn ON Color Channel
Common Cathode (Most Common in Kits) Connects to Ground (GND) Send a HIGH signal (5V) to R, G, or B pin
Common Anode Connects to Power (5V) Send a LOW signal (GND) to R, G, or B pin

[!IMPORTANT] The STEMAIDE Coder-Kit contains a Common Cathode RGB module. In this manual, all wiring diagrams and programming codes assume the Common pin connects to GND on the Arduino Uno.


Circuit Safety and Current Limiting

Since the RGB LED houses three separate light-emitting diodes, each individual color channel (Red, Green, Blue) requires its own current-limiting resistor when connected to an Arduino output pin.

  • Connecting the pins directly to 5V without resistors will burn out the LED channels.
  • Typically, 220Ω resistors are placed in series with the Red, Green, and Blue control pins.
  • Note: The Red channel has a lower forward voltage than Green and Blue. In advanced designs, a slightly higher resistor value (like 330Ω) is sometimes used on the Red channel to balance brightness, but 220Ω is standard for simple kit projects.

Controlling Colors using PWM

To control the brightness of each color channel individually, you must connect the R, G, and B pins of the module to PWM-enabled pins on the Arduino Uno. On the Arduino Uno, PWM pins are marked with a tilde symbol (~), such as pins 3, 5, 6, 9, 10, and 11.

Instead of using digitalWrite(pin, HIGH) (which only turns a channel 100% ON or OFF), you use the analogWrite(pin, value) function: * The value ranges from 0 (completely OFF) to 255 (fully ON). * For example, calling analogWrite(redPin, 255) and analogWrite(bluePin, 128) will mix full red with half-brightness blue, creating a vibrant purple shade.