Learn

Your Arduino LED will not light, or it is dim: what to check

  • 192parts on the bench
  • 25boards running now
  • 1.00xreal time, on every board
Arduino Uno: the LED that workslive0.000 s 0.00x
Click to open it in the editor
A red LED and 220 ohms on pin 13, blinking. Open it in the editor, then break one thing at a time.

An LED that does nothing is the first real bug almost everyone meets, and it is rarely the LED. The circuit above is the version that works: an Arduino Uno, a red LED, a 220 ohm resistor and pin 13, blinking once a second. Everything on this page is a way to make that circuit fail, in roughly the order the causes turn up on a real desk, with what each one looks like so you can tell them apart.

Open it in the editor and break it on purpose as you read. A wrong wire costs nothing here, and seeing each fault once makes it much faster to recognize on the bench.

It glows, but only faintly: check pinMode

If the LED is dim rather than dark, look for `pinMode(pin, OUTPUT)` in `setup()`. Without it the pin is still an input, and `digitalWrite(pin, HIGH)` on an input does not drive the pin. It switches on the chip’s internal pull-up resistor instead, about 35 kilohms on an Uno, so the only current reaching the LED comes through that. It is around a tenth of a milliamp instead of fifteen.

We ran exactly that on the circuit above: the same sketch with and without the pinMode line. Without it, the LED gets less than one percent of its normal current. On screen that looks off; on a real board in a dim room you can often see a faint glow, which is the giveaway. The Arduino reference describes the same symptom on its digitalWrite page. The fix is one line, and it belongs in `setup()`, once for every pin that drives something.

Blink with both lines that are easy to leave out
const int LED_PIN = 13;

void setup() {
  pinMode(LED_PIN, OUTPUT);  // without this line the LED is dim
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(500);
  digitalWrite(LED_PIN, LOW);
  delay(500);  // without this line the LED looks always on
}

It never turns off, or never seems to blink

A common first sketch turns the LED on, waits, turns it off, and stops there. `loop()` then starts again at once, so the LED is off for a few microseconds and on for the whole delay. It looks permanently lit. In our run of that sketch the LED’s brightness never visibly moved from full. Every change of state needs its own delay after it.

The opposite happens with very short delays. At `delay(5)` the LED switches a hundred times a second, far faster than your eye follows, and it just looks steady at about half brightness. If an LED looks dim and pinMode is there, check that the timing is what you meant.

It is dark: check the LED’s direction

An LED is a diode and only conducts one way. The longer leg is the anode and goes toward the Arduino pin, through the resistor; the shorter leg, on the side where the rim of the LED has a flat edge, is the cathode and goes to GND. Backwards, it draws no current at all and does not light, and no amount of code will change that. Turning a reversed LED around is the single most common fix, and it does not harm the LED at 5 volts.

In the editor, select the LED and press R to rotate it until the cathode faces ground. With the LED reversed, the simulated LED passes no current, exactly like the real one.

It is dark: check the breadboard

Each group of five holes in a breadboard row is one connection, and the groups on either side of the center channel are not joined. An LED with both legs in the same five-hole strip is shorted and stays dark; a wire one hole off lands in the next strip over. The long power rails along the edges are separate from the rows, and on many full-size breadboards each rail is also split in the middle, which a gap in the printed red or blue line gives away.

The last common one is ground. The LED’s cathode has to reach one of the Arduino’s GND pins, either directly or through a rail that is wired to it. A rail that is not connected to the board is not ground, however much it looks like it. The breadboard guide goes through the layout hole by hole.

It is dim: check the resistor’s value

Kits mix 220 ohm, 1 k, 10 k and 100 k resistors, and they look alike. A 220 ohm resistor is red, red, brown; a 10 k one is brown, black, orange. A 10 k in the LED’s place makes it very dim, and it is easy to do.

Here is what the simulator measured with a red LED on a 5 volt pin, compared with the 220 ohm current: 330 ohms gives about 70 percent, 1 k about a quarter, 10 k about 3 percent. Your eye is not linear, so 330 and 220 look almost the same and 10 k looks nearly off. Color matters too: blue and white LEDs need about 3 volts instead of about 2, so on the same 220 ohms they get roughly two thirds of the current a red one does.

It does nothing: check the pin number

The code has to write the pin the wire is actually on. Keep the number in one constant at the top, like `LED_PIN` above, and use that name everywhere, so changing the wiring means changing one line. On an Uno, `LED_BUILTIN` is pin 13, which also drives the small L LED on the board; if that one blinks and yours does not, the code is fine and the fault is in your wiring.

The analog pins, A0 to A5, work as digital outputs too, so `pinMode(A0, OUTPUT)` is fine. Pins 0 and 1 carry the serial port on a real Uno, so an LED there gets in the way of printing and uploading, and is best put somewhere else.

analogWrite does nothing, or only on and off

An Uno can only fade an LED on pins 3, 5, 6, 9, 10 and 11, the ones marked with a tilde (~) on the board. On any other pin, `analogWrite` cannot make PWM, so the Arduino core rounds it: a value below 128 turns the pin fully off, 128 and above turns it fully on. `analogWrite(13, 100)` therefore leaves the LED dark, which looks like a wiring fault and is not. Mokxi’s Uno runtime does the same, so you can see it in the circuit above by changing the sketch. Move the LED to pin 9 and the fade works.

A fade, on a pin that can do it
const int LED_PIN = 9;  // 3, 5, 6, 9, 10 or 11 on an Uno

void setup() {
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  for (int level = 0; level <= 255; level++) {
    analogWrite(LED_PIN, level);
    delay(4);
  }
  for (int level = 255; level >= 0; level--) {
    analogWrite(LED_PIN, level);
    delay(4);
  }
}

Last: the LED or the pin is damaged

An LED wired straight to a pin with no resistor draws far more than the 20 milliamps an Uno pin is meant to supply (the ATmega328P datasheet gives 40 mA as the absolute maximum), and either the LED or the pin can fail. To check the LED, put it with a 220 ohm resistor between the board’s 5V and GND pins; if it lights, the LED is fine. To check the pin, move the wire and the code to another pin.

This is the one cause a simulator cannot show. Mokxi does not burn out LEDs or pins, so a circuit that works here and not on the desk, after every other check on this page, points at a damaged part.

Questions

Why is my Arduino LED so dim?

Most often, pinMode(pin, OUTPUT) is missing, so digitalWrite only turns on the weak internal pull-up. After that, check for a resistor that is too large (10 k instead of 220) and for a blink so fast it averages out.

Which leg of an LED goes to the Arduino pin?

The longer leg, the anode, goes toward the pin through the resistor. The shorter leg, on the side with the flat edge, goes to GND.

Can I connect an LED to an Arduino without a resistor?

Not safely. Nothing limits the current except the pin itself, which is pushed past its 20 mA rating. Use 220 to 330 ohms for a red LED on 5 V.

Why does the built-in LED blink but my LED does not?

Then the code runs and pin 13 is switching, so the fault is in the external circuit: the LED’s direction, the breadboard strip, the resistor or the ground wire.

Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.