How to Wire an LED: Resistor Values for 3.3V, 5V, 12V and 24V

This guide gets a 3mm or 5mm LED lit on the supply you actually have: a 3.3V ESP32 pin, a 5V Arduino or USB supply, a 12V plug-pack, a car, boat or caravan, or a 24V system. It covers which leg goes where, the resistor value for each colour and supply, wiring several LEDs together, and when a pre-wired LED with the resistor already fitted saves you the job. For how resistors work in general, with colour bands and a calculator, see our guide on how to wire a resistor.

In this guide
  1. Which leg is which
  2. Forward voltage by colour
  3. Resistor values for 3.3V, 5V, 12V and 24V
  4. Cars, boats and caravans: work it out at 14.4V
  5. Running an LED from an Arduino or ESP32 pin
  6. Several LEDs: series or parallel
  7. Flat-top or round, diffused or water-clear
  8. When a pre-wired LED saves the work
  9. A two-minute test
  10. Troubleshooting
  11. Questions

Which leg is which

An LED only lets current through one way, so it has a positive and a negative leg. The long leg is the anode (+) and goes towards the positive supply. The short leg is the cathode (-) and goes towards GND. The rim around the base has a small flat on the cathode side, which still tells you which is which after you trim the legs.

Every bare LED needs a resistor in series to set its current. One resistor, one LED, all in one line: supply to resistor, resistor to the long leg, short leg to GND. The resistor can go on either side of the LED, and either way round.

Diagram of a round LED with the long anode leg marked plus, the short cathode leg and the flat on the rim marked minus, beside a circuit from the positive supply through a resistor and the LED to GND, and a pre-wired LED with its red lead to positive and black lead to GND
Long leg to +, short leg and flat rim to GND, one resistor in line. A pre-wired LED has the resistor inside the heat-shrink, so red goes to + and black to GND. Not to scale.

Forward voltage by colour

An LED uses up a fixed slice of the supply voltage, called its forward voltage. Red, orange, yellow and green use about 2V. Blue and white use about 3V. The resistor takes whatever is left over, so the colour decides the resistor value. These are the figures for our own 3mm and 5mm LEDs at 20mA:

Colour 3mm LEDs 5mm LEDs
Red 1.8 to 2.0V 1.8 to 2.2V
Orange 1.8 to 2.0V Not in the 5mm range
Yellow 1.8 to 2.0V 1.8 to 2.0V
Green 1.8 to 2.0V (yellow-green) 2.0 to 2.4V
Blue 3.0 to 3.2V 3.0 to 3.2V
White 3.0 to 3.2V 3.0 to 3.2V

20mA is the most we suggest for these LEDs. For an indicator, 5 to 10mA is plenty, and every value in the next table aims for about 10mA.

Resistor values for 3.3V, 5V, 12V and 24V

Find your supply, then read across to your LED colour. The red and green column covers orange and yellow too. Every value here is in our 600-piece resistor kit, and the current shown is the most you will see, so a real LED runs at or a little under it.

Supply Red, green Blue, white
3.3V (ESP32 or Pico pin) 150 ohm, 6 to 10mA 47 ohm, 2 to 6mA (dimmer)
5V (Arduino pin or USB) 330 ohm, 8 to 10mA 220 ohm, 8 to 9mA
12V regulated (plug-pack, bench supply) 1k, about 10mA 1k, about 9mA
12V vehicle, boat or caravan 1k, about 12mA at 14.4V 1k, about 11mA at 14.4V
24V regulated 3.3k, about 6.5mA 3.3k, about 6.3mA
24V truck or vehicle 4.7k, about 5.7mA at 28.8V 4.7k, about 5.5mA at 28.8V

A 1/4W resistor covers every row. The hardest-working one is the 1k at 14.4V, which turns about 0.16W into heat, so it feels warm to the touch. At 24V the resistor values step up to 3.3k and 4.7k to keep that heat down, which is why those rows sit nearer 6mA. The LED is still clearly lit at that current, and if you want it brighter on 24V, run two or more LEDs in series (see Several LEDs).

For a supply that isn't in the table, use the LED resistor calculator in our resistor guide. Put in 2V for red, orange, yellow or green, 3V for blue or white, and 10mA, then round up to the next value you have.

Cars, boats and caravans: work it out at 14.4V

A 12V battery only sits near 12V when nothing is charging it. Once the engine is running, the alternator holds the system at about 13.8 to 14.4V, and a solar or shore-power charger on a boat or caravan does much the same. An LED's current rises fast with that extra 2V, because the resistor's share of the voltage grows while the LED's stays put.

Here is what that does to a red LED with a 560 ohm resistor, worked out for about 18mA on a 12V bench supply:

18.2mAat 12.0V, engine off
22.5mAat 14.4V, engine running
20mAour limit for these LEDs

So for anything on a vehicle, boat or caravan, work the resistor out at 14.4V and check it still looks bright enough at 12V. With the 1k from the table, a red LED runs at about 12mA with the engine running and 10mA with it off, so it stays inside the limit all day. Trucks and buses on 24V charge at about 28.8V, which is why the table's vehicle row for 24V uses 4.7k.

A 12V pre-wired LED in a vehicle is fine for a switch or warning light that is on now and then. For a dash light that stays on for hours while you drive, use a bare LED with a 1k resistor, or feed the pre-wired LED from a regulated 12V supply.

Running an LED from an Arduino or ESP32 pin

A board's output pin can power one LED through its resistor. An Arduino Uno or Nano pin gives 5V, so use the 5V row of the table. An ESP32 pin gives 3.3V, so use the 3.3V row. With those values each LED draws 10mA or less, and we suggest keeping any one pin under 20mA.

Wire the pin to the resistor, the resistor to the long leg and the short leg to GND, then upload this sketch. Use pin 13 on an Uno or Nano, or change ledPin to 4 for GPIO4 on an ESP32.

const int ledPin = 13;  // 4 on an ESP32

void setup() {
  pinMode(ledPin, OUTPUT);  // needed for full brightness
}

void loop() {
  digitalWrite(ledPin, HIGH);  // LED on
  delay(500);
  digitalWrite(ledPin, LOW);   // LED off
  delay(500);
}

The LED flashes on and off twice a second. On an Uno, the small LED marked L on the board flashes with it, because it shares pin 13. For a first project, the garage parking sensor in our HC-SR04 ultrasonic sensor guide lights green, amber and red LEDs as the car gets closer.

Two things catch people out here. If the LED glows only faintly, the sketch is missing pinMode(ledPin, OUTPUT);, so the pin is feeding the LED through the chip's weak internal pull-up instead of driving it. And blue or white LEDs on a 3.3V ESP32 pin have only about 0.3V left over for the resistor, so they light more softly, and less evenly from one LED to the next, than on 5V. Red, yellow and green suit a 3.3V board best.

A 12V LED, a long string or anything over 20mA needs its own supply, switched by the pin. A 5V relay module or 3.3V relay module does that with no extra parts. For many LEDs or dimming, an NPN transistor such as a 2N2222, with a 1k resistor between the pin and its base, is the usual choice.

Several LEDs: series or parallel

There are two good ways to run several LEDs from one supply, and one to avoid.

Three circuits on 12V: three red LEDs in series with one 680 ohm resistor, three LEDs in parallel each with its own 1k resistor, and a crossed-out circuit of three LEDs side by side sharing one resistor
Series: one resistor for a string of LEDs. Parallel: one resistor per LED. Avoid LEDs side by side on one shared resistor.

Series means end to end, long leg to short leg, with one resistor for the whole string. The LEDs' voltages add up, and the resistor takes what is left. It saves resistors and wastes less power as heat, but the string needs enough supply voltage, and if one LED fails the whole string goes out.

Parallel means each LED gets its own resistor, and each LED-and-resistor pair connects across the supply. Each one works on its own, so one failure leaves the rest lit.

Avoid wiring LEDs side by side on one shared resistor. No two LEDs have exactly the same forward voltage, so the one with the lowest takes most of the current, runs brighter and wears out first.

String Supply Resistor
3 red, orange, yellow or 3mm green 12V regulated 680 ohm, 8 to 10mA
3 red, orange, yellow or 3mm green 12V vehicle (14.4V) 1k, 8 to 9mA running, 5 to 7mA engine off
2 blue or white 12V vehicle (14.4V) 1k, about 8mA running, 6mA engine off
6 red, orange, yellow or 3mm green 24V regulated 1k, 11 to 13mA

Leave at least 2V for the resistor. Three blue LEDs on 12V leave it only 2.4 to 3V, so the current swings with every small change in supply voltage, and on a running engine it nearly doubles. Two blue or white LEDs per string is the safe number for a vehicle.

Flat-top or round, diffused or water-clear

The lens shape and finish decide where the light goes and how the LED looks when it is off.

Lens What you see Good for
Round top The dome sends most of the light straight ahead. Our 3mm round water-clear LED spreads it over about 45 degrees. Indicators you look at head-on, and lights that need to reach across a room
Flat top The light spreads wide and looks even from the side. Model windows and lamps, and lights behind a panel or seen at an angle
Diffused A soft, even glow you can see from the side. Tinted diffused lenses show their colour even when off. Status lights on a front panel, and sorting colours in the parts drawer
Water-clear Looks clear when off and gives a bright, tight point of light. Our 5mm water-clear white is rated 14,000 to 16,000mcd, two to three times our 3mm white. Headlights in models, and lights that need to stand out in daylight

Size is about the hole you drill. A 3mm LED fits a 3mm hole, and its rim, about 3.9mm across, stops it pushing through. A 5mm LED fits a 5mm hole. Both have 2.54mm leg spacing, so either size plugs straight into a breadboard.

When a pre-wired LED saves the work

A pre-wired LED comes with the resistor fitted under heat-shrink and about 20cm of red and black lead, so you strip and join two wires and it lights. It is the quicker choice for a 12V panel, a vehicle switch or a model, where soldering a resistor to each LED would take longer than the job itself. Our rocker switch guide shows how to wire one as an on-light beside an unlit rocker. A bare LED with your own resistor is cheaper, suits a breadboard, and is the way to go when you need a supply or current that a pre-wired LED isn't made for, such as 24V.

LED Supply Worth knowing
3mm diffused 5V version or 12V version Match the version to your supply. Red, green and white come in 5V, and all six colours in 12V.
5mm diffused, 12V 12V DC Six colours. The white has a water-clear lens.
5mm flat-top water-clear and 3mm flat-top water-clear 3 to 12V DC Brighter as the voltage rises. Red, yellow and orange are bright from about 3V, and the other colours look their best from 5V. A 5V Arduino pin can run one directly. UV and colour-changing RGB are in the range too.
3mm round water-clear 3 to 12V DC Under 20mA, with a mounting base for each LED. Ten colours plus fast and slow colour-changing.
2mm white diffused 5V DC, 7V at most The smallest head we have, with a wide, even glow for tight spots in models.

Each pre-wired LED goes straight across the supply, red to + and black to GND. To have one come on when a hatch, door or lid opens, put a limit switch in its positive lead, as shown in our micro limit switch guide. To run several from one supply, connect each one across it on its own, which is the parallel wiring from above with the resistors already fitted. None of them is made for 24V, so on a 24V system use bare LEDs with the 24V resistor from the table, or a 12V/24V to 5V step-down converter to run 5V pre-wired LEDs.

A two-minute test

Before you wire a whole panel, test one LED on a breadboard. Our breadboard basics guide shows how the rows connect.

  1. Use 5V. An Arduino's 5V and GND pins, or a 5V USB supply, are both fine.
  2. Fit a red LED and a 330 ohm resistor. Run 5V to the resistor, the resistor to the long leg, and the short leg to GND.
  3. Look for a steady red glow. If it stays dark, turn the LED round. A correct LED and resistor light straight away.

Once one works, swap in your real supply and the resistor from the table.

Troubleshooting

What you see What to do
The LED stays dark Turn it round so the long leg faces +. Then check the GND wire reaches the supply's negative.
It glows faintly from an Arduino pin Add the pinMode line from the sketch above to your setup.
Blue or white is dim on an ESP32 3.3V leaves little for the resistor. Use red, yellow or green on 3.3V, or power the LED from 5V through a relay module or transistor.
It flashed bright once and died It had no resistor, or one far too small. Fit a new LED with the value from the table.
One LED in a group is brighter than the rest They are sharing one resistor side by side. Give each LED its own resistor.
A series string won't light The LEDs need more voltage than the supply gives. Use fewer per string, leaving at least 2V for the resistor.
Fine in the garage, burns out on the road The resistor was worked out at 12V. Work it out at 14.4V, or use the vehicle row of the table.
A 12V pre-wired LED is very dim It is on 5V. Use the 5V version of the 3mm diffused LED, or a flat-top water-clear LED.
The resistor gets hot The value is too small for the supply. On 24V, use 3.3k or more.

Questions

Is this the same as an LED load resistor for my car's indicators?

No. A load resistor is a large power resistor fitted beside LED indicator bulbs so the flasher doesn't flash too fast. It doesn't light anything. This guide is about the small resistor that sets an LED's own current.

What wattage of resistor do I need?

A standard 1/4W resistor covers every value in this guide. None of them turns more than about 0.17W into heat, so the busiest ones feel warm but stay well inside the rating.

How do I make an LED dimmer?

Use a bigger resistor. Doubling the resistor roughly halves the current, so 2k instead of 1k on 12V gives about 5mA. From a board you can also dim it with analogWrite(), which switches the pin on and off too fast to see.

Do the colour-changing LEDs need a controller?

No. The RGB flash and colour-changing pre-wired LEDs have the timing built in, so you wire them like any other colour and they cycle on their own.

Not sure which LED or resistor?

Tell us your supply voltage, the colour and how many LEDs, and we'll tell you what to use.

Practical help from New Zealand

Still stuck? Send us a photo.

Tell us what you’re building and what the circuit is doing. Our small NZ team knows these parts and can help you spot a wiring problem or choose what you need next.

Ask NZN for help Browse more guides