RGB LED

A three-input luminous output that mixes red, green and blue light additively to produce a color. Each of its three inputs controls one channel. With single-bit inputs each channel is simply on or off, giving the eight primary/secondary colors of additive mixing (red + green = yellow, red + blue = magenta, green + blue = cyan, all three = white). Real full-color RGB LEDs go further: they drive each channel with 8 bits of brightness, so 8 + 8 + 8 = 24 bits encode 256 x 256 x 256 = 16,777,216 colors, the origin of '24-bit true color'.

Basic

Additive color mixing

Wire three switches to the R, G and B inputs. Each combination lights a different color. With one bit per channel there are exactly eight results: turning channels on together adds their light, so red and green together read as yellow and all three together read as white. This is additive mixing, the opposite of mixing paint.

RGBColor
000off
100red
010green
001blue
110yellow
101magenta
011cyan
111white
Intermediate

From 3 bits to 24-bit color

One bit per channel gives 2 x 2 x 2 = 8 colors. Real RGB LEDs assign 8 bits to each channel, encoding 256 brightness levels per color. Concatenated as R[7:0] G[7:0] B[7:0] that is a 24-bit word, and 2^24 = 16,777,216 possible colors. This is exactly how a web color like #3B82F6 works: 0x3B red, 0x82 green, 0xF6 blue.

From 3 bits to 24-bit color
Advanced

PWM color fading

Because the human eye averages fast blinking, you can dim a single-bit channel by pulsing it: a channel driven at a 50% duty cycle looks half as bright. Driving R, G and B with clocks at different duty cycles blends smoothly toward any hue, which is how a microcontroller fakes 24-bit color from on/off pins. This pulse-width-modulation trick is the software counterpart of the hardware 8-bit-per-channel brightness.

PWM color fading

Citations

  • Worldsemi Co., Ltd. (2015). WS2812B intelligent control LED integrated light source [Data sheet]. Reference 1
  • Holonyak, N., Jr., & Bevacqua, S. F. (1962). Coherent (visible) light emission from Ga(As₁₋ₓPₓ) junctions. Applied Physics Letters, 1(4), 82–83. Reference 2