RGB LED Color Mixer

Mix any colour and get hex, RGB565, Arduino PWM values for common-cathode or common-anode RGB LEDs, resistor values and ready-to-copy code.

  • Free, no signup
  • Works on mobile
  • Formula + worked example

How to use the RGB LED colour mixer

  1. Pick a colour with the colour picker, type a hex code (like #EA580C), drag the R, G and B sliders, or tap a preset.
  2. Choose your LED type: common cathode (shared leg to GND) or common anode (shared leg to + supply). The PWM values update instantly.
  3. Tick gamma-correct if you want the LED to look closer to the colour on your screen.
  4. Choose the supply voltage (5 V or 3.3 V) and current to get a resistor for each colour.
  5. Set your PWM pins and press Copy code for a ready-made Arduino sketch.

How an RGB LED makes colours

An RGB LED is three LEDs — red, green and blue — in one package. Using PWM (pulse-width modulation), the microcontroller switches each colour on and off hundreds of times per second. Your eye averages the flicker, so a channel that is on 50% of the time looks about half as bright. Mixing the three brightness levels gives you thousands of colours.

Formula

Common cathode: analogWrite(pin, value) value = 0…255 Common anode: analogWrite(pin, 255 − value) Duty cycle (%) = PWM value ÷ 255 × 100 Gamma (γ 2.2): level = 255 × (value ÷ 255)^2.2 RGB565 = (R >> 3) << 11 | (G >> 2) << 5 | (B >> 3) Resistor R = (V_supply − V_f) ÷ I

Typical values (5 V supply, 10 mA per colour)

ColourTypical V_fExact resistorUse (E24)Current
Red2.0 V300 Ω300 Ω10.0 mA
Green3.0 V200 Ω200 Ω10.0 mA
Blue3.1 V190 Ω200 Ω9.5 mA

These forward voltages are typical values for small 5 mm RGB LEDs; your LED's datasheet may differ slightly. On a 3.3 V supply, green and blue have only 0.2–0.3 V left for the resistor, so they may look dim and uneven — 5 V gives more reliable colours.

Common mistakes

  • Wrong LED type. If your colours look "inverted" (white when you asked for black), you have a common-anode LED — switch the type and re-copy the code.
  • Using non-PWM pins. On an Arduino Uno or Nano only pins 3, 5, 6, 9, 10 and 11 support analogWrite(). On ESP32 and Raspberry Pi Pico most GPIO pins can do PWM.
  • Common anode on 5 V with a 3.3 V board. Connect the common leg to 3.3 V, otherwise the LED may not switch fully off.
  • Expecting an exact screen match. LEDs and screens produce colour differently; gamma correction gets you closer.

Learn how PWM works in PWM explained: LED dimming and motor speed, and convert duty cycles with the PWM duty cycle calculator. For single LEDs, use the LED resistor calculator. Driving a small TFT screen? RGB565 colours work with our TFT tool. Not sure which board to use? Read Arduino vs ESP32 vs Raspberry Pi Pico, find more ideas in our science exhibition project list, or start with an Arduino kit.

Frequently asked questions

What is the difference between common cathode and common anode RGB LEDs?+

In a common-cathode LED the shared (longest) leg goes to GND and each colour lights when its pin goes HIGH. In a common-anode LED the shared leg goes to the positive supply and each colour lights when its pin goes LOW, so the PWM value is inverted: analogWrite(pin, 255 − value).

Why does my RGB LED colour not match the screen?+

The three LED chips have different brightness, and our eyes see brightness non-linearly. Green usually looks strongest. Try the gamma-correction option, and adjust the resistor values (for example a slightly larger resistor on green) to balance the colours.

Which resistor values should I use for an RGB LED on 5 V?+

With typical forward voltages (red 2.0 V, green 3.0 V, blue 3.1 V) at 10 mA: red ≈ 300 Ω, green ≈ 200 Ω and blue ≈ 190 Ω (use 200 Ω). Each leg needs its own resistor.

Which Arduino pins can I use for an RGB LED?+

You need three PWM pins. On an Arduino Uno or Nano those are 3, 5, 6, 9, 10 and 11. On the ESP32 and Raspberry Pi Pico almost any GPIO pin can output PWM.

What is RGB565?+

RGB565 packs a colour into 16 bits — 5 bits red, 6 bits green and 5 bits blue. Most small TFT displays used with Arduino and ESP32 take colours in this format. For example #EA580C becomes 0xEAC1.

From the Thinking Robot store

Shop all
All tools
WhatsApp