Skip to content

Beginning of the lesson

What is an RGB LED?

An RGB LED is actually three LEDs in one package - a Red, Green, and Blue LED combined together. By mixing these three primary colors of light at different intensities, we can create virtually any color!

Additive Color Mixing

Unlike paint (subtractive mixing), light uses additive mixing:

  • Red + Green = Yellow
  • Green + Blue = Cyan
  • Red + Blue = Magenta
  • Red + Green + Blue = White
Interactive visualization — available in the full lesson

Common Cathode RGB LED

Common Cathode (CC) means all three LED cathodes (negative legs) are connected together internally and share one pin that goes to GND.

PinConnectionControl
Red AnodeThrough resistor to PWM pinHIGH = ON
Green AnodeThrough resistor to PWM pinHIGH = ON
Blue AnodeThrough resistor to PWM pinHIGH = ON
Common CathodeDirectly to GNDAlways GND
Logic: analogWrite(pin, 255) = Full brightness, analogWrite(pin, 0) = OFF

Common Anode RGB LED

Common Anode (CA) means all three LED anodes (positive legs) are connected together internally and share one pin that goes to 5V.

PinConnectionControl
Red CathodeThrough resistor to PWM pinLOW = ON
Green CathodeThrough resistor to PWM pinLOW = ON
Blue CathodeThrough resistor to PWM pinLOW = ON
Common AnodeDirectly to 5VAlways 5V
Logic: analogWrite(pin, 0) = Full brightness, analogWrite(pin, 255) = OFF (inverted!)

Continue this lesson on YourAIZone

The full lesson has the complete explanation, worked examples, common mistakes, tests with instant checking and an AI tutor. Start right away as a guest, or create an account to keep your progress.

In the full lesson

  • The complete explanation
  • Worked examples
  • Common mistakes and how to avoid them
  • Test questions: 15
  • AI tutor that answers questions about the topic
  • Progress tracking for students, parents and teachers