ohmio

Circuits / Microcontrollers

Arduino UNO: an RGB LED mixes colours (PWM)

Three LEDs in one dome, each with its own resistor: their brightness, set by PWM, adds up to the colour the eye sees

Arduino UNO: an RGB LED mixes colours (PWM), simulated on a breadboard

Tap a part to see its voltages and currents. It is a model, not a measurement.

What do you need?

How does an Arduino mix colours with an RGB LED?

An RGB LED is three small LEDs in one dome, red, green and blue, sharing one leg: here the common cathode, tied to GND. Each chip has its own pin and resistor: D9, D10 and D11, through 220 Ω each. They need separate resistors because red asks for less voltage, about 1.9 V against 3 V for green and blue. So the same 220 Ω gives red about 12 mA and the other two about 7.6 mA. analogWrite sets each chip's share of the time on, from 0 to 255, switching about 490 times per second. The chips are too close and too fast for your eye to separate, so it adds them: red and green look yellow, green and blue cyan, red and blue magenta, all three white. The program's last colour, 255 red with 40 green, is orange: green is on only about 16 % of the time. To balance the white, change the resistors, since equal resistors do not give equal light.

Values from the Protoboard ISO simulation: a model, not a bench measurement.