An RGB LED simulator that mixes any color
Mokxi is a free online RGB LED simulator that runs in your browser, with nothing to install and no account needed. An RGB LED on three PWM pins of an Arduino Uno, each leg through its own 220 ohm resistor. The sketch hands the light from red to green to blue and back, so the color walks all the way around the wheel.
- 455parts on the bench
- 43boards running now
- 1.00xreal time, on every board
What you can do here
In the circuit above, or in the editor it opens.
- Mix any color with analogWrite on three pins
- Switch the LED between common cathode and common anode
- Change a resistor and see the balance of the color move
- Measure each color’s current with a multimeter
- Fade through ten named colors in the RGB color mixer project
- Light a whole strip of NeoPixels instead
What the running circuit shows
Three LEDs under one lens.
An RGB LED is a red, a green and a blue LED in one package, here with their cathodes joined on the long leg. analogWrite sets each one from 0 to 255 on pins 6, 5 and 3, and the eye blends the three. The sketch cross-fades: as one value falls from 255 to 0 the next rises from 0 to 255, so the total stays the same and only the hue moves.
In the engine each hand-over is 256 steps of 8 ms, so the serial monitor says “green”, “blue” and “red” about two seconds apart, and one trip around the wheel takes about six seconds. Pins 6 and 5 switch at about 980 Hz and pin 3 at about 490 Hz, because they come from different timers, and the eye sees none of it.
How the LED is modeled
Three diodes, each with its own forward voltage.
Each die is a diode with its own curve, solved with the resistors and the pins. At full brightness the red die drops about 1.7 V and takes about 13 mA through its 220 ohm resistor; the green and blue dies drop about 2.8 V and take about 9 mA. That is why the same 255 on all three comes out pinkish rather than white, and why the RGB color mixer project turns red down to balance it.
Common anode is a property: flip it and the shared leg goes to 5 V, a LOW lights a color, and the sketch has to write 255 minus each value. What it leaves out: the color on screen is the engine’s estimate of the blend, and a real LED’s three dies sit side by side, so up close a real one shows color fringes this one does not.
Questions
Is it free?
Yes. The circuit on this page, every part in it and the editor it opens in are on the free plan, with no card.
Do I need an account?
No. The circuit runs the moment the page does, and the editor opens without one. A free account is only for saving a project to the cloud and sharing it by link.
How do I make white with an RGB LED?
Turn all three on, then turn red down. On equal resistors the red die takes more current than the others, because it drops less voltage, so all three at 255 comes out pinkish; the RGB color mixer project writes 170 to red for its balanced white.
Common anode or common cathode?
Common cathode has the shared leg on ground and HIGH lights a color; common anode has it on 5 V and LOW lights a color. Set the part’s common property to match, and for common anode write 255 minus each value.
Which pins can fade an RGB LED on an Uno?
The PWM pins, marked with a ~: 3, 5, 6, 9, 10 and 11. This circuit uses 6, 5 and 3.
More simulators
Each one opens on a circuit that is already running.
Mix a color
Open the circuit, change the colors and press Run. Nothing to install, and no account needed.