Mix colours with an RGB LED
An RGB LED is three LEDs in one dome that share one leg. Give each colour its own resistor and plug the colours in with wires, and the same dome makes red, green, blue and every mix of them. The mix is not the one the numbers suggest: three equal resistors lean violet, and a meter shows why.
You need one RGB LED, three 220 Ω resistors, four jumper wires and the power module on the breadboard. Build with the module unplugged from USB. This is the first circuit three times over, sharing one leg.
Three LEDs and one shared leg
The dome holds three LEDs, one red, one green, one blue. Each has two connections, so there could be six legs, and there are four: the three LEDs share one of theirs. One of the four is longer than the rest, and that is the shared leg.
There are two kinds, and the listing does not say which one this is. In a common cathode part the shared leg is the cathode of all three, and it goes to the − rail. In a common anode part it is the anode of all three, and it goes to the + rail. Both are sold in kits like this one, and everything else about the circuit is the same turned upside down. The next section finds out in half a minute.
Find out which kind you have
Put the meter on its diode range, the symbol that looks like a diode, and touch the probes to two legs. The meter pushes a small current out of the red probe and back into the black one, which is the same thing the circuit will do, so it lights a die whenever the current goes through it the right way.
Try the long leg with the black probe and each other leg with the red one. If a colour glows, the long leg is the cathode: common cathode. If nothing lights, swap the probes. A colour that glows when the red probe is on the long leg means common anode. Each colour that lights is also telling you which leg it is on, so write down which leg gave which colour: the usual order from the flat side is red, long, green, blue, and that order is a habit, not a rule.
Some meters give too little voltage in this range to light green or blue, which need about 3 V. If only red glows, carry on to the build and test with the power module instead.
One resistor for each colour
It is tempting to put one resistor on the shared leg and be done. It does not work, and the figure shows why.
With one resistor shared, the three LEDs are in parallel with one another. Whichever needs the least voltage sets it for all of them, and that is red: it conducts at about 2 V and holds the shared point there, so green and blue, which need about 3 V, get nothing. Three colours are asked for and one lights. Give each colour its own resistor and each carries its own current whatever the others do.
Build it
The figure builds the common cathode version: the long leg's row to the − rail, and one wire from the + rail to each resistor. Each wire is the switch for its colour, which is the only switch in the circuit. If yours is common anode, swap the roles of the rails: the long leg's row goes to the + rail and each wire goes from a resistor's far row to the − rail. The module's switch stays on 5 V (which way round the module goes).
Plug the USB-C cable in last. Plug in one colour wire at a time, and pull one out again to see that only that colour goes.
Eight colours
Three wires, each in or out, is eight combinations. Click any of them.
Red and green make yellow, green and blue make cyan, red and blue make magenta, and all three make something near white. Those are the colours the figure draws; yours may be a little different, because a screen is not an LED and because no two LEDs are alike.
Equal resistors are not equal colours
All three resistors are 220 Ω, and the three dies do not behave alike. The module's 5 V side reads about 4.8 V (why). Red takes about 2 V, so the resistor gets 2.8 V and passes about 12.7 mA. Green and blue take about 3 V, so their resistors get 1.8 V and pass about 8.2 mA.
The eye sees the light, not the current. Green looks brighter than red at the same current and blue looks much dimmer, and white needs about a third red, three fifths green and hardly any blue. So equal resistors leave the mix short of green with too much blue, and it leans violet. The TinkerBlock RGB handbook works the same idea out from a datasheet.
Pick the resistors for each colour. The nearest the box's six values get to white is 220 Ω on red and blue and 100 Ω on green. That runs the green die at about 18 mA, which is under the 20 mA these dies are usually rated for and close to it, so it is a thing to try for a minute, not to leave on. The figure's light shares come from datasheet ratios for a part of the same kind, and your LED will differ: judge by eye, with a sheet of white paper held behind the dome.
Mix one colour by hand
Wire a potentiometer in series with one colour's resistor and turn it. One is enough to see the idea.
Here the trimmer sits in the green branch, in series with the 100 Ω. At its low-resistance end green carries its full 18 mA, so start with the trimmer turned the other way, and bring it down slowly. The other two colours do not move, because each has its own resistor. The 1 kΩ potentiometer is the one that uses the whole turn, as in the dimmer.
Measure it
Set the meter to DC volts and read each colour's LED and its resistor, one colour at a time, with the other two wires out. A meter on its volts range draws almost no current, so touching the probes to the legs does not change the circuit. The table is for three 220 Ω resistors on the 5 V side with a 4.8 V rail; switch to the other set to see 100 Ω on green.
| Colour | Resistor | Across the LED | Across the resistor | Current | Light |
|---|---|---|---|---|---|
| Red | 220 Ω | 2.00 V | 2.80 V | 12.7 mA | 12.7 |
| Green | 220 Ω | 3.00 V | 1.80 V | 8.18 mA | 13.9 |
| Blue | 220 Ω | 3.00 V | 1.80 V | 8.18 mA | 3.5 |
| Between | Expect | What it means |
|---|---|---|
| Red leg and the long leg | about 2.0 V | The red die is conducting. |
| Red's resistor | about 2.8 V | The rest of the rail. Divide by 220: about 12.7 mA. |
| Green or blue leg and the long leg | about 3.0 V | These need about a volt more than red. |
| Green's or blue's resistor | about 1.8 V | Divide by 220: about 8.2 mA. |
In each row the LED and the resistor add up to the rail, within a few hundredths of a volt. If they do not, a leg is not where you think it is. Stay on the volts range: the current is the resistor's reading divided by its value, and putting the meter on a current range across the LED can blow its fuse.
With all three wires in, the rail is carrying about 29 mA, far inside the module's half amp. The LEDs differ by a few tenths of a volt from these numbers, so yours will read a little differently, and that is fine.
On the 3.3 V side
Switch the module to 3.3 V and the same circuit gives red about 5.9 mA and green and blue about 1.4 mA each, because 3.3 V leaves only a few tenths of a volt for the resistors beyond the 3 V the dies take. Red is lit, green and blue are dim, and a die that happens to need 3.2 V may look dark. Every mix then leans red. It is not a fault: it is the same reason blue was dim in the first circuit.
When it does not work
Two usual causes. One resistor is shared by all three colours instead of one each: red needs the least voltage, so it takes the current and the others stay dark. Or the module is on its 3.3 V side, where red still gets about 6 mA and green and blue get under 2 mA each. Check that each colour has its own resistor, and the module's switch.
The LED is probably common anode, and the circuit was built for common cathode. Run the meter test again. If a colour lights when the red probe is on the long leg, turn the circuit upside down: the long leg to the + rail, and each resistor's free leg to the − rail instead. If it is common cathode and still dark, look for the wire from the long leg's row to the − rail.
The order of the legs is not the same on every part. The usual order from the flat side is red, the long leg, green, blue, but yours may differ. Find each colour with the meter, one leg at a time with the other probe on the long leg, and wire to what you find, not to what a picture says.
Green and blue need about 3 V to conduct, and the meter's diode range may give less. It does not mean the dies are dead. Build the circuit and test with the power module instead: it gives 4.8 V on the 5 V side, which is plenty for all three.
That is what three equal resistors do. Green's light is worth more to the eye than red's, and blue's is worth much less, so equal currents leave green short and blue high. Swapping green to a smaller resistor moves the mix toward white. It will not be exact: the six values in the box are coarse steps.
The same three LEDs on a board with a microcontroller, where a pin per colour replaces your hand on the wire.
Mixing with PWM →Edit this page — content/books/estkit/mix-colours-with-an-rgb-led.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Electronics Starter Kit, Breadboard, Power Module and Components
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.