I find current to be one of the trickiest concepts to grasp in introductory electronics. Part of this is because current does not behave the same way in all components. Part of it is because current flow is tied to both your power supply, the thing being powered ( fancy term == load) and the total impact of all parts in a circuit.
Current Flows in LEDs
This Building Block explores how current flows through an LED. It also explains why we use current limiting resistors with LED and how to calculate their size.
Recall Ohm’s Law
Resistors follow Ohm’s law
Current flows through a resistor following Ohm’s law (V=IR). For a fixed resistor — say one of our favourites like a 1K Ω (brown, black, red) — Ohm’s law tells us that if we increase voltage across the resistor, we will proportionally increase current.
LEDs are Different
LEDs act differently. They are diodes — Light Emitting Diodes! And diodes are semiconductors. So, they follow slightly different rules (for a deeper dive into this).
We have seen that our LEDs block current and do not light up when placed in a circuit ‘backwards’ (fancy term == reverse biased). We have also seen that they glow delightfully when placed in circuits with their flat sides to ground (fancy term == forward biased).
Characteristic Forward Voltage
The amount of voltage required to turn an LED on, or make it glow, is called the characteristic forward voltage (VF). The exact value is dependant on the diode — it differs slightly for each color — but is usually 1.4-4V. At the maker / creative level of electronics, that we are exploring, most people assume 2V.
Break Down VOltage
If you exceed the characteristic voltage and give the LED more V than it takes to turn on, then the resistance of the LED drops very fast. When this happens Ohm’s law tells us that LED will use (fancy term == draw) a whole bunch of current. This can, in some cases, lead to LED burn out; along with electric melting smells, LED caps occasionally becoming projectiles and a total lack of glow.
Avoiding LED meltdowns
In addition to a forward voltage spec, LEDs have a characteristic forward current or recommended operating current that should not be exceeded. We can protect our LEDs from the rapid current increases by placing a resistor in series (one after the other) with the LED. We call these resistors current limiting resistors. Note any resistor can be current limiting as long as its placed in series with the LED — its the placement of the component not its brand or type or materiality that makes it current limiting.
Calculating Resistor Size
With this bit of background understood we can jump into determining the size of resistor we need to protect our LEDs.
Let’s assume we are using our basic LED circuit. In this circuit we have a power supply (V), an LED with a set operating (forward) current (I) and a series resistor (R) that limits the current.
We can use Ohm’s law to calculate the size of resistor needed.
In the image above, cover the R and see that resistance (R) is calculated by dividing V / I. Simple. But what V and what I?
We should know V for the circuit — it will be a battery pack of known voltage (9V from out kits) or from Arduino pin (5V for an Uno). If you power up with other sources make sure you know the voltage!
The Power of Data Sheets
Current limits can only be reliably found in the data sheet of the LED you are using. To find this you need to know what LED you have in hand, i.e. what part you bought.
Data sheets are technical documents that outline everything you could want to know about a component. The data sheet for our RED LEDs is mercifully short; only 3 pages. The data sheet for the microcontroller on an Arduino Uno is longer than 300 pages.
The first page of the red LED sheet tells us everything we need to know. It includes the following chart:
Recall that two values are needed for our calculation — forward voltage (turn on voltage – red), and operating current (sometime called forward current- blue).
Forward voltage is listed as being between 1.7 and 2.6V with 2.1V indicated as typical.
Operating current is 10 mA or 0.010A. Max listed as 50mA ( 0.050A). If you exceed the max of 50mA, the LED is a goner.
Formal Calculation
For our basic circuit we can calculate resistor size using the following formula:
where:
R == size of resistor we need
Vs == source voltage ( battery or Arduino for us)
Vf == forward (turn on) voltage of the LED
I == operating current of LED — in AMPS (A). Often this current is listed in mA (milliAmps). If so, you will have to divide mA by 1000 to convert to amps (A).
Battery Powered Resistor
For the battery powered LED and resistor circuit that we started this course with (Alligator Clip Circuit) we would have the following values in the formula:
Which gives a resistance of 690Ω.
(You can confirm with a calculator or back of an envelope).
We do not have a 690Ω resistor in our kit (though they exist — what would their color bands be ? ). Instead, we go to the next size up; which in our case is 1KΩ.
Quick and Dirty Calculation
Given that we are making experiences and creatively applying electronics, not making heart rate monitors, we can take a few short cuts. Engineers close your eyes for a moment.
You can simplify this calculation — and I do this all the time — by ignoring the forward voltage of the LED. If you don’t have a data sheet you could also use 2V and apply rule above.
The resulting simplified formula looks like this:
And for our red LEDs with a recommended current of 10mA (.010A) — we would calculate R = 9/0.010 == 900Ω. The closest, next bigger resistor in our kit is 1KΩ. This is the same result as above!
When you ignore forward voltage you end up with a calculation that OVER ESTIMATES the resistance needed. In other works you will use a bigger than needed resistor. The trade off is a circuit with a slightly less bright LED (usually undetectable) in a circuit with too much protection. I think its a good trade-off when data sheets aren’t handy.
What if we don’t know LED current?
It is common in maker tutorials to see people assume the LED current is 20mA (.020A). This a compromise / guess — and it happens because most kits and parts you buy online will not have readily available links to component data sheets.
If you don’t have a data sheet this is generally a good point of departure for LED current. If you use this and things get hot or you melt an LED, get the next bigger resistor in your kit.
This simplified formula for cases when LED current and LED voltage are both unknown is:
For our 9V circuit we would calculate R= 9V/0.020A == 450Ω.
Closest, next largest resistor in our kit is 470Ω. This is smaller than the 1K predicted above.
Current flow with a red LED would be I = V/R == 9/470 == 0.019mA — which is much less than peak current limit. So, you may shorten its life but it won’t explode.
Arduino Pin Considerations
When we connect any circuit to an Arduino pin we need to also consider the current limits of the Arduino.
Each individual pin can handle an absolute limit of 40mA (0.040) based on data sheet (Arduino site says 20mA). However, the Arduino Uno as a whole — all the current, in all the connected circuits, added up, can not exceed 200mA (0.20A).
As our circuits get more complex, we will need to pay attention!
What resistor do we need if we have a 5V I/O pin and unknown LED current and voltage limits.
In his case we use the simplified formula and assume 20mA through the LED. This is less than the Arduino pin limit and should be LED safe.
R == 5V/0.020 == 250Ω. Bigger than our 100Ω resistor, but less than 470Ω — so use at least a 470Ω kit resistor.
If we account for LED forward voltage and use data sheet current.
R == 5-2.1 / 0.01 == 290Ω.
Again, select at least 470Ω.
Playing Safe, Protect your Arduino = 1KΩ
Because of the Arduino hard limit of 200mA — I generally build simple LED circuits with 1kΩ resistors. This means slightly dimmer LEDs than may be possible, but helps keep total current low.
At 5V and 1000Ω (1k) the current supplied by a pin is <5mA. You could safely put one of these on every i/o pin and not exceed the total device limit!
Going Further
Explore the ideas in these ideas intuitively — in LED + Resistor = Brightness
More about arduino power limits.
GREEN LED from kit — data sheet