This part has a page of its own, with a note on using it and a circuit to try: the part page.
Two legs on the breadboard: A the anode, C the cathode. Current has to flow from
A to C to light it, and the color property is red, green, blue, yellow or white.
It changes the forward voltage as well as the color, because a real LED's drop
depends on what it is made of.
Pins
| Pin | What it does |
|---|---|
A |
Anode. Current goes in here. |
C |
Cathode, the shorter leg on a real part. Current comes out here. |
Properties
color: red, green, blue, yellow or white. It changes the picture and the die:
each color is specified by its drop at 20 mA, which is how a datasheet
specifies one. Red 1.8 V, yellow 2.0 V, green 3.0 V, blue 3.0 V, white 3.1 V.
The split is the die, not the lens: red and yellow are AlGaInP and sit under 2.2 V, green, blue and white are InGaN and sit near 3. That volt of difference is why a series resistor is worked out per color rather than copied, and it is what decides whether a lamp will run at all off a 3.3 V board. A modern 5 mm green is InGaN; the 2.1 V green of the textbooks is a GaP die.
What the model gets right
The LED is a diode and the diode is the Shockley equation,
I = Is (exp(Vj / (N Vt)) - 1), with N = 2 and 12 ohm of bulk resistance, and
the color's drop at 20 mA is what sets Is. So the drop is not a number the
part carries around: it is whatever the curve gives at the current the circuit
is passing. A 5 V rail through 220 ohm lights a red LED at 14.9 mA with
1.72 V across it, and the same LED on 3.3 V through 220 ohm passes 7.7 mA
at 1.60 V. The drop falls with the current, which is what a real LED does and
what a fixed drop could never show.
Blue and white drop 3.0 V and 3.1 V, because that is what a real blue die does, so a blue LED on 5 V through 220 ohm passes 9.8 mA. On a 3.3 V rail it passes only 2.8 mA, which is the real reason a blue LED looks dim on a 3.3 V board.
The LED loads the net it is on, the way a real diode does, and below about a nanoamp of forward current it lets go of both nets entirely: no leakage, no reverse current. The probe is not the instantaneous brightness either: it is an 8 ms rolling average of it, the same time constant your own retina uses, so a PWM-dimmed LED reads as dimmed rather than as a random flicker.
What it does not model
One curve per color, and no spread. Real LEDs of the same color vary by a couple of hundred millivolts from part to part; every red LED here is the same red LED. The bulk resistance is 12 ohm and the emission coefficient 2 for every color, which is the middle of the range indicator LEDs sit in rather than a measurement of any one part.
No junction capacitance and no temperature. The junction is at 27 C and stays there, where a real LED's drop moves about 2 mV a degree, and it switches in nothing flat. There is no reverse breakdown either: reverse biased it passes its saturation current, which is femtoamps, however much you put across it.
Full brightness is 20 mA and the probe stops there. Brightness is the forward current divided by 20 mA and clamped at 1, so 20 mA and 200 mA look identical on the canvas even though the probe reports the current honestly.
The glow is drawn as bright as it looks. The eye does not see light in
proportion: seen brightness goes roughly as the cube root of the light, the CIE
lightness curve, and the canvas draws the probe through that curve. So an LED on
1 k from 5 V (3 mA, 15% of its rated current) looks about 45% lit, as it does on
the bench, rather than nearly off, and a linear analogWrite fade looks nearly
full for most of its travel and falls away at the bottom. The probe itself is
still the light, current over 20 mA averaged the way the eye averages a PWM.
It burns out
A 5 mm LED is rated 20 mA, with an absolute maximum around 30 mA. Push much more than that through it for more than a moment and a real one dies.
The first time it happens to an LED in the editor, it gets a warning instead: it glows amber, keeps working, and a message says how much current it took, what its limit is, and that a real one would have burned out. The next time, in the same run or any later one, it burns out the way a real one does: it flashes, goes dark and cracked, and from then on it is an open circuit until you press Run again. The editor remembers which parts it has warned about until you open another project or reload the page. The Checkup lists both.
How much is too much: it survives 60 mA held for ever (three times its rating, twice its absolute maximum), and it heats on the square of the current with a time constant of 10 ms. Straight across 5 V with nothing in series is a quarter of an amp and it is gone in well under a millisecond; a board pin straight into a red or green LED (65 to 80 mA) takes a few tens of milliseconds. Any sensible resistor (100 ohm or more at 5 V) keeps it under 30 mA and it never burns, and neither does a PWM whose average heating is under the limit, however high its peaks. In between, say 47 ohm at 5 V (about 56 mA), a real LED dims and fails over minutes or hours; that slow death is not modeled, so here it lives, and the probe tells you the current honestly.
Common mistakes
The one everybody makes once: no series resistor. An LED with nothing limiting its current is not "a bit bright", it is a short dressed up as a component, and the resistor that should be next to it is the whole of Ohm's law protecting the LED.
See it in action
Blink is the first sketch on every board Mokxi has, and Hello, breadboard, Knight Rider and LED bar chaser all build on nothing more than an LED and a resistor. Browse the full set at /templates, or read how faithfully a part behaves for what the canvas models and what it leaves out.
How many LEDs can one Arduino pin drive? measures one to eight LEDs on one pin, and ten on ten pins, against the ATmega328P's limits.
The LED part page draws it live, with its pins and every project that uses one.