Electronics

LED resistor calculator: what resistor for 12 V?

Work out the series resistor for an LED on 12 V, 5 V or any supply. Rounds up to a standard value and shows the current and the resistor's power.

For a red LED on a 12 V supply at 20 mA, use a 510 Ω resistor. This calculator works out the resistor for any supply voltage, LED colour and current, rounds up to a value you can buy, and shows the power the resistor must handle. The default settings below are that 12 V example.

The LED resistor calculator needs JavaScript switched on in your browser.

The formula, and why it works

An LED does not behave like a normal resistor. Once it is switched on, the voltage across it stays close to one value, called its forward voltage (Vf), and the current rises very quickly if you push the voltage a little higher. With nothing to limit the current, an LED on a 12 V supply draws far more than it can take and fails. The series resistor takes up the voltage the LED does not use and fixes the current.

The resistor has to drop the supply voltage minus the LED’s forward voltage, at the current you want. Ohm’s law (resistance = voltage ÷ current) gives:

R = (Vs − Vf) ÷ I

Vs is the supply voltage in volts, Vf is the LED’s forward voltage in volts, and I is the current in amps. A common mistake is to put the current in milliamps: 20 mA is 0.02 A. For several LEDs in one series string, subtract the forward voltages of all of them. The breadboard LED circuit article builds the same circuit on a 9 V battery; this page is for other supplies.

Worked example: a red LED on 12 V

  1. Supply voltage: 12 V. A red LED has a forward voltage of about 2.0 V.
  2. Voltage across the resistor: 12 V − 2.0 V = 10 V.
  3. Current wanted: 20 mA = 0.02 A.
  4. Resistance: 10 V ÷ 0.02 A = 500 Ω.
  5. 500 Ω is not a standard value. Choose the next one up, 510 Ω. Rounding up keeps the current at or below your target. The real current is 10 V ÷ 510 Ω = 19.6 mA.
  6. Power in the resistor: 10 V × 0.0196 A = 0.196 W (196 mW).

That last step matters at 12 V. A common through-hole resistor is rated ¼ W (0.25 W), sometimes ½ W, according to SparkFun’s resistor guide. A ¼ W part carrying 0.196 W is close to its limit and will run hot, so the calculator advises a ½ W resistor, which carries the load at under half its rating. Lowering the current solves it too: at 10 mA the resistor is 1 kΩ and carries 0.1 W, which a ¼ W part handles comfortably.

Resistors for a 12 V supply, by LED colour

The table uses typical forward voltages and the E24 series, rounding up. The forward voltages are starting points, not guarantees: use the figure in your LED’s datasheet when you have it.

LED colour (Vf used) 20 mA: exact 20 mA: use 10 mA: exact 10 mA: use
Red (2.0 V) 500 Ω 510 Ω 1,000 Ω 1 kΩ
Yellow or amber (2.1 V) 495 Ω 510 Ω 990 Ω 1 kΩ
Green, traditional (2.2 V) 490 Ω 510 Ω 980 Ω 1 kΩ
Blue (3.2 V) 440 Ω 470 Ω 880 Ω 910 Ω
White (3.2 V) 440 Ω 470 Ω 880 Ω 910 Ω

At 20 mA the 12 V resistors carry 165 to 196 mW, so use ½ W parts. At 10 mA they carry 85 to 100 mW, and ¼ W parts are fine.

The same red LED on other supplies

Supply 20 mA: exact 20 mA: use (E24) 10 mA: exact 10 mA: use (E24)
3.3 V 65 Ω 68 Ω 130 Ω 130 Ω
5 V 150 Ω 150 Ω 300 Ω 300 Ω
9 V 350 Ω 360 Ω 700 Ω 750 Ω
12 V 500 Ω 510 Ω 1,000 Ω 1 kΩ
24 V 1,100 Ω 1.1 kΩ 2,200 Ω 2.2 kΩ

Which value to buy: E12 or E24

Resistors are made in standard series, not every value. According to Wikipedia’s article on preferred numbers, E12 has 12 values per decade for 10% tolerance and E24 has 24 values for 5%. E24 steps are smaller, so the resistor is closer to the exact answer. If you only have a mixed E12 kit, choose E12 in the calculator: 500 Ω becomes 560 Ω, and the current falls to 17.9 mA, which is safe but a little dimmer.

Check your LED’s datasheet: forward voltage and maximum current

Both numbers in the formula come from the LED, and they vary. Wikipedia’s table of LED colours gives about 1.63 to 2.03 V for red, 2.48 to 3.7 V for blue and 2.7 to 3.5 V for white. Green covers a very wide range, 1.9 to 4.0 V, because older and newer green LEDs use different materials. If your green LED looks very bright and pure, try 3.0 V or more.

The maximum current varies too. Rapid Electronics’ datasheet for its 5 mm normal red LED (55-1790) gives a maximum DC forward current of only 15 mA, and a forward voltage of 2.2 V typical and 2.8 V maximum (measured at 20 mA, which is above that maximum current). Its 5 mm bright red LED (55-1796) is rated at 30 mA, with 1.7 V typical and 2.6 V maximum. So 20 mA suits the second LED but is too much for the first. When you are unsure, 10 mA is a safer starting point.

A higher supply voltage also makes the result less sensitive to the LED’s own variation. With the 510 Ω resistor on 12 V, forward voltages of 1.7 V and 2.6 V give 20.2 mA and 18.4 mA. The same LEDs on 5 V with 150 Ω give 22.0 mA and 16.0 mA.

LED resistor for a car or other 12 V vehicle supply

A 12 V vehicle system is not exactly 12 V. According to Wikipedia’s article on automotive batteries, the charging system holds 13.5 to 14.5 V with the engine running, and a fully charged battery rests at about 12.6 V. The calculator therefore shows the current at 14.5 V when you enter a supply near 12 V. For the 510 Ω example it is 24.5 mA instead of 19.6 mA. If that is too high for your LED, enter 14.5 V as the supply instead: the LED is then a little dimmer when the engine is off, but never over its limit. Take the supply from a fused circuit.

Several LEDs: series or parallel

  • In series (one after another), the same current flows through all of them, so one resistor is enough. Add up the forward voltages. Three red LEDs on 12 V at 20 mA need (12 − 6) ÷ 0.02 = 300 Ω. Set “LEDs in series” to 3 to check. The supply must be higher than the total forward voltage.
  • In parallel, give each LED its own resistor. Two LEDs of the same type still differ slightly in forward voltage, and the one with the lower voltage takes more than its share of the current. One resistor per LED keeps each current fixed.

Safety and common mistakes

  • Polarity. An LED conducts one way only. The longer leg is the anode (positive). Rapid’s datasheets give a maximum reverse voltage of 5 V, so connecting an LED backwards to 12 V can damage it.
  • Resistor position. It can sit on either side of the LED; the current is the same.
  • Hot resistors. If a resistor is too hot to touch, check its power with the calculator and use a higher rating or a lower current.
  • Do not round down. A resistor below the calculated value gives more than the intended current.

Related guides

Learn what the component is in What are resistors and how do they work?, then try the resistor with a timing circuit in flashing an LED with a 555 timer. More calculators are on the Free tools page, and there are more guides in Electronics.

FAQ

What resistor do I need for an LED on 12 V?

For a red LED at 20 mA, 510 Ω (exact value 500 Ω). For a white or blue LED at 20 mA, 470 Ω. At 10 mA, use about 1 kΩ for red and 910 Ω for white or blue. Use ½ W resistors at 20 mA and ¼ W at 10 mA.

What happens if I use a resistor that is too small or too large?

Too small, and the current is higher than planned, so the LED gets hot and its life is shortened or it fails. Too large, and the current is lower, so the LED is dimmer but safe. When in doubt, go up in value.

Can I connect an LED straight to 12 V?

No. Without a resistor or a current-limiting driver, the current is only limited by the supply and the LED itself, and the LED is usually damaged. Always use a series resistor, or buy an LED with a built-in resistor and check its voltage rating.

Sources: E series of preferred numbers (Wikipedia); Light-emitting diode (Wikipedia); Automotive battery (Wikipedia); SparkFun, Resistors: power rating; Rapid Electronics datasheet 55-1790; Rapid Electronics datasheet 55-1796. Calculations by Braindumps; checked with code.

Use this calculator on your own site

You are welcome to use this calculator on your own website. Copy the code below into a Custom HTML block in WordPress, or into any web page. It needs no other files. We only ask that you keep the link to Braindumps at the bottom.

<!-- Braindumps LED resistor calculator (UK): works out the series resistor for one or more LEDs. Self-contained: no external files. -->
<div id="bd-ledr">
<style>
#bd-ledr{--bd-red:#d63333;--bd-line:rgba(127,127,127,.35);--bd-soft:rgba(127,127,127,.08);font:inherit;color:inherit;max-width:760px;margin:1.5em 0}
#bd-ledr *{box-sizing:border-box}
#bd-ledr [hidden]{display:none!important}
#bd-ledr fieldset{border:1px solid var(--bd-line);border-radius:10px;padding:14px 16px 6px;margin:0 0 14px;min-width:0}
#bd-ledr legend{font-weight:700;padding:0 6px}
#bd-ledr .grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:0 14px}
#bd-ledr label{display:block;font-size:.92em;margin-bottom:10px}
#bd-ledr input,#bd-ledr select{width:100%;padding:9px 10px;margin-top:4px;border:1px solid var(--bd-line);border-radius:6px;font:inherit;background:transparent;color:inherit}
#bd-ledr select option{color:#000;background:#fff}
#bd-ledr .chips{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 10px}
#bd-ledr .chips button{padding:5px 12px;border:1px solid var(--bd-line);border-radius:999px;background:transparent;color:inherit;font:inherit;font-size:.9em;cursor:pointer}
#bd-ledr .chips button:hover{border-color:var(--bd-red)}
#bd-ledr .seg{display:flex;flex-wrap:wrap;gap:8px;margin:0 0 10px;border:0;padding:0}
#bd-ledr .seg label{display:flex;align-items:center;gap:6px;margin:0;padding:7px 14px;border:1px solid var(--bd-line);border-radius:999px;cursor:pointer;font-size:.92em}
#bd-ledr .seg input{width:auto;margin:0;accent-color:var(--bd-red)}
#bd-ledr .seg label:has(input:checked){border-color:var(--bd-red);background:var(--bd-soft);font-weight:700}
#bd-ledr .result{border:2px solid var(--bd-red);border-radius:10px;padding:12px 16px;background:var(--bd-soft)}
#bd-ledr .big{font-size:1.6em;font-weight:700;margin:0 0 4px}
#bd-ledr table{width:100%;border-collapse:collapse;margin:8px 0 0}
#bd-ledr td{padding:6px 0;border-bottom:1px solid var(--bd-line)}
#bd-ledr td:last-child{text-align:right;font-variant-numeric:tabular-nums;font-weight:700;white-space:nowrap}
#bd-ledr .warn{margin:10px 0 0;padding:8px 12px;border-left:4px solid var(--bd-red);background:var(--bd-soft);font-size:.92em}
#bd-ledr .note{margin:10px 0 0;font-size:.92em}
#bd-ledr details{margin-top:8px}
#bd-ledr summary{cursor:pointer;font-weight:700}
#bd-ledr pre{white-space:pre-wrap;font-size:.85em;margin:8px 0 0;background:transparent;border:0;padding:0}
</style>

<fieldset>
<legend>Your circuit</legend>
<label>Supply voltage (V)<input id="bd-ledr-vs" type="number" min="0" step="0.1" value="12" inputmode="decimal"></label>
<div class="chips" aria-label="Common supply voltages">
<button type="button" data-v="3.3">3.3 V</button><button type="button" data-v="5">5 V</button><button type="button" data-v="9">9 V</button><button type="button" data-v="12">12 V</button><button type="button" data-v="24">24 V</button>
</div>
<div class="grid">
<label>LED colour<select id="bd-ledr-col">
<option value="2.0" selected>Red (about 2.0 V)</option>
<option value="2.1">Yellow or amber (about 2.1 V)</option>
<option value="2.2">Green, traditional (about 2.2 V)</option>
<option value="3.2">Blue (about 3.2 V)</option>
<option value="3.2w">White (about 3.2 V)</option>
<option value="other">Other: type the voltage</option>
</select></label>
<label>LED forward voltage (V)<input id="bd-ledr-vf" type="number" min="0" step="0.05" value="2" inputmode="decimal"></label>
<label>Current wanted (mA)<input id="bd-ledr-ma" type="number" min="0" step="1" value="20" inputmode="decimal"></label>
<label>LEDs in series<input id="bd-ledr-n" type="number" min="1" max="20" step="1" value="1" inputmode="numeric"></label>
</div>
<fieldset class="seg" role="radiogroup" aria-label="Standard resistor values">
<label><input type="radio" name="bd-ledr-ser" value="E24" checked> E24 (5% resistors)</label>
<label><input type="radio" name="bd-ledr-ser" value="E12"> E12 (fewer values)</label>
</fieldset>
</fieldset>

<div class="result" aria-live="polite">
<p class="big" id="bd-ledr-big"></p>
<table><tbody>
<tr><td>Exact value</td><td id="bd-ledr-exact"></td></tr>
<tr><td>Standard value to buy (next one up)</td><td id="bd-ledr-std"></td></tr>
<tr><td>Actual current with that resistor</td><td id="bd-ledr-act"></td></tr>
<tr><td>Power in the resistor</td><td id="bd-ledr-pow"></td></tr>
<tr><td>Resistor power rating to buy</td><td id="bd-ledr-watt"></td></tr>
</tbody></table>
<div class="warn" id="bd-ledr-warn" hidden></div>
<p class="note" id="bd-ledr-car" hidden></p>
<details><summary>Show the working</summary><pre id="bd-ledr-working"></pre></details>
</div>

<p class="bd-credit" style="font-size:.85em;opacity:.75;margin:10px 0 0">LED resistor calculator by <a href="https://braindumps.co.uk/led-resistor-calculator/">Braindumps.co.uk</a></p>
<script>
(function () {
  "use strict";
  /* BEGIN CALC */
  var E12 = [1.0, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.7, 5.6, 6.8, 8.2];
  var E24 = [1.0, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1];
  var RATINGS = [0.25, 0.5, 1, 2, 5];
  function nextStandard(ohms, series) {
    var base = series === "E12" ? E12 : E24;
    var target = ohms * (1 - 1e-9);
    for (var decade = 0; decade <= 7; decade++) {
      for (var i = 0; i < base.length; i++) {
        var v = Number((base[i] * Math.pow(10, decade)).toPrecision(8));
        if (v >= target) { return v; }
      }
    }
    return null;
  }
  function ratingFor(watts) {
    for (var i = 0; i < RATINGS.length; i++) {
      if (watts <= RATINGS[i] / 2 + 1e-12) { return RATINGS[i]; }
    }
    return null;
  }
  function ledCalc(vs, vf, mA, n, series) {
    var vfTotal = vf * n;
    var amps = mA / 1000;
    if (!(vs > 0) || !(vf > 0) || !(mA > 0) || !(n >= 1)) { return { ok: false, reason: "input" }; }
    if (vs <= vfTotal) { return { ok: false, reason: "voltage", vfTotal: vfTotal }; }
    var drop = vs - vfTotal;
    var exact = drop / amps;
    var std = nextStandard(exact, series);
    if (std === null) { return { ok: false, reason: "range" }; }
    var actual = drop / std;
    var power = drop * drop / std;
    return { ok: true, vfTotal: vfTotal, drop: drop, exact: exact, std: std, actualMA: actual * 1000, power: power, rating: ratingFor(power) };
  }
  /* END CALC */
  function $(id) { return document.getElementById("bd-ledr-" + id); }
  function fmtOhms(r) {
    if (r >= 1e6) { return (Math.round(r / 1e4) / 100) + " MΩ"; }
    if (r >= 1e3) { return (Math.round(r / 10) / 100) + " kΩ"; }
    return (Math.round(r * 100) / 100) + " Ω";
  }
  function num(x, dp) { return (Math.round(x * Math.pow(10, dp)) / Math.pow(10, dp)).toString(); }
  function wattText(w) { return w === 0.25 ? "¼ W" : w === 0.5 ? "½ W" : w + " W"; }
  var colourV = { "2.0": 2.0, "2.1": 2.1, "2.2": 2.2, "3.2": 3.2, "3.2w": 3.2 };
  function update() {
    var vs = parseFloat($("vs").value), vf = parseFloat($("vf").value), mA = parseFloat($("ma").value);
    var n = Math.round(parseFloat($("n").value));
    var ser = document.querySelector('input[name="bd-ledr-ser"]:checked').value;
    var r = ledCalc(vs, vf, mA, n, ser);
    var warn = $("warn"), car = $("car");
    warn.hidden = true; car.hidden = true;
    if (!r.ok) {
      $("big").textContent = r.reason === "voltage" ? "The supply is too low for this LED." : "Fill in every box with a number above zero.";
      ["exact", "std", "act", "pow", "watt"].forEach(function (k) { $(k).textContent = "–"; });
      $("working").textContent = "";
      if (r.reason === "voltage") {
        warn.textContent = n + " × " + num(vf, 2) + " V = " + num(r.vfTotal, 2) + " V, which is not less than the " + num(vs, 2) + " V supply. The LEDs will not light properly. Use fewer LEDs in series, or a higher supply voltage.";
        warn.hidden = false;
      }
      return;
    }
    $("big").textContent = "Use a " + fmtOhms(r.std) + " resistor";
    $("exact").textContent = fmtOhms(r.exact);
    $("std").textContent = fmtOhms(r.std) + " (" + ser + ")";
    $("act").textContent = num(r.actualMA, 1) + " mA";
    $("pow").textContent = num(r.power * 1000, 0) + " mW";
    $("watt").textContent = r.rating ? wattText(r.rating) : "more than 5 W (use several resistors or another method)";
    var msgs = [];
    if (mA > 30) { msgs.push("Most 5 mm LEDs are rated for 20 to 30 mA at most, and some for only 15 mA. Check your LED's datasheet before using " + num(mA, 0) + " mA."); }
    if (r.drop < 1.5) { msgs.push("Only " + num(r.drop, 2) + " V is left for the resistor, so small differences between LEDs will change the current a lot. A higher supply voltage or fewer LEDs in series gives a steadier result."); }
    if (msgs.length) { warn.textContent = msgs.join(" "); warn.hidden = false; }
    if (vs >= 11.5 && vs <= 12.5) {
      var hi = (14.5 - r.vfTotal) / r.std * 1000;
      car.textContent = "In a vehicle, a 12 V system is 13.5 to 14.5 V with the engine running. At 14.5 V this resistor passes " + num(hi, 1) + " mA.";
      car.hidden = false;
    }
    var lines = [];
    lines.push("Voltage across the resistor = " + num(vs, 2) + " V − " + (n > 1 ? n + " × " : "") + num(vf, 2) + " V = " + num(r.drop, 2) + " V");
    lines.push("Exact resistance = " + num(r.drop, 2) + " V ÷ " + num(mA / 1000, 3) + " A = " + num(r.exact, 1) + " Ω");
    lines.push("Next " + ser + " value up = " + fmtOhms(r.std));
    lines.push("Actual current = " + num(r.drop, 2) + " V ÷ " + num(r.std, 1) + " Ω = " + num(r.actualMA, 2) + " mA");
    lines.push("Power in the resistor = " + num(r.drop, 2) + " V × " + num(r.actualMA / 1000, 4) + " A = " + num(r.power * 1000, 1) + " mW");
    lines.push("Rating chosen so the resistor runs at no more than half its limit.");
    $("working").textContent = lines.join("\n");
  }
  function setColour() {
    var v = $("col").value;
    if (colourV[v] !== undefined) { $("vf").value = colourV[v]; }
    update();
  }
  $("col").addEventListener("change", setColour);
  $("vf").addEventListener("input", function () { $("col").value = "other"; update(); });
  ["vs", "ma", "n"].forEach(function (k) { $(k).addEventListener("input", update); });
  Array.prototype.forEach.call(document.querySelectorAll('input[name="bd-ledr-ser"]'), function (e) { e.addEventListener("change", update); });
  Array.prototype.forEach.call(document.querySelectorAll("#bd-ledr .chips button"), function (b) {
    b.addEventListener("click", function () { $("vs").value = b.getAttribute("data-v"); update(); });
  });
  update();
})();
</script>
</div>

Get new Braindumps guides by email

One email a week with new guides, the best free 3D prints, LEGO news and tools. Unsubscribe at any time.

No spam. Read our privacy policy.