Part

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

See every part
  • 2 pins
  • 1 setting
  • In 153 projects
  • In 177 lessons
Drawn live by the editor's own code, at the size you see it.
At a glance

The LED in brief

What it is, and every setting the properties panel gives it.

An LED is a diode, not a resistor. Below about 1.5 volts a red one barely conducts; past that its current climbs exponentially with the voltage across it, so it takes whatever the rest of the loop can push through it while its own drop hardly moves. That is why an LED always needs a series resistor to set its current, never a bare wire to the supply: the resistor is what actually does the limiting. Mokxi models the Shockley equation itself rather than a fixed drop, so the anode net sits where the curve puts it (1.72 V for a red LED at 14.9 mA, and lower at lower currents) at whatever value the circuit’s resistor sets. What you see is not the instantaneous state either. The probe is a short-lived average of the LED’s brightness, with a time constant close to 8 milliseconds, the same range the eye’s own response takes, which is why a fast-blinking or PWM-dimmed LED here looks the way it would on a real bench rather than flickering once per switch.

Family
Basics
Pins
2
color
red (or green, blue, yellow, white)
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.

A circuit built around it, running and explained: the LED circuit simulator.

Pins

2 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
What it does
A
Anode. Current goes in here.
C
Cathode, the shorter leg on a real part. Current comes out here.
How to use it

How to wire an LED to an Arduino

An LED only lights one way around. The long leg is the anode (A): it goes toward the pin. The short leg, on the flat side of the rim, is the cathode (C): it goes toward GND. Put a resistor in series, 220 ohms for a 5 V board, so the pin does not push more current through the LED than either can take.

Then pinMode(pin, OUTPUT) and digitalWrite(pin, HIGH) light it. On a PWM pin, analogWrite(pin, 0 to 255) dims it. The circuit here is the first one most people build: an LED and a 220 ohm resistor on pin 13, blinking once a second.

Part pin
Board pin
Anode (A, long leg)
Pin 13, through 220 ohms
Cathode (C, short leg)
GND

On a 3.3 V board such as an ESP32 or a Pico, a 100 to 150 ohm resistor gives a red LED about the same brightness, and the LED pin in the sketch changes: GPIO 2 on an ESP32 DevKit, GP25 on the Pico.

Arduino Uno: first blinklive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
Blink, the sketch this circuit runs
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);   // pin 13 on an Uno
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(500);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);
}
How it is modeled

What is true about the LED, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

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.

Not modeled

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.

LEDs, seven-segment dies and RGB LEDs (`led`)

modelwhat sets it
the same equation, with N = 2 and 12 ohm of bulkthe color's drop at 20 mA: red 1.8 V, yellow 2.0, green 3.0, blue 3.0, white 3.1

From LED, in full.

Projects

See the LED in a project

153 built-in projects use it. Each opens in the editor, already wired.

Lessons

Where it turns up in a lesson

177 lessons place it in their own circuits.

Learn articles

166 lessons

Wire up the LED

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.