# Choosing a Resistor for your LED

I got an Arduino (Uno) for Christmas! Now that I’ve expressed my excitement, I’ll continue on to the rest of this post.

A standard introduction to Arduino is to turn an LED on and off from some pin.  However, for the circuit to be safe (for both your Arduino and your LED), the circuit needs some resistor.  In this blog post, I’ll explain how to select the right resistor for your LED.  At the end of the post, I have a video that demonstrates the entire process (calculations and all) with my Arduino and LED.

An LED is a very interesting electrical component.  It has something called a “turn-on voltage,” or more commonly, the “forward voltage.”  When given an input voltage less than the forward voltage, it acts as if it has infinite resistance (and doesn’t light up).  But, when given an input voltage greater than the forward voltage, its resistance drops to essentially 0 ohms, and lights up.

Because its resistance drops to 0 ohms, having a circuit containing only an LED is essentially a short between power and ground.  What does this mean?  Well, let’s look at Ohm’s Law:

$$I = \frac{V}{R}$$
As R becomes smaller and smaller, I becomes larger and larger.  If R were to approach 0, then I would approach infinity.  Your Arduino has limits on how much current it can supply from any of its pins, and and your LED has limits on how much current it can take.  Regardless of the limit, a current approaching infinity would certainly be above it.

Side Note:  What are these limits?  Per the Arduino Uno information page, the Arduino can supply 40mA of current through each IO pin.  Your LED’s maximum current will vary, but a typical LED can take about 20mA.  We will target 15mA to be on the safe side.

Thus, we need some way of limiting the current of the circuit. The easiest way to do this is by increasing the overall resistance in the circuit.  So, we add a resistor.  But what size?  That is what this post aims to answer.

Circuit diagram for LED

Above is the general circuit diagram for an LED controlled by pin 12 of your Arduino.  Over the course of the circuit, you have a total voltage “drop” of 5V (the pin outputs 5V, and at ground the voltage is 0 volts).  How much is the voltage drop across the LED?  You can measure this with a voltmeter on the diode setting.  For my LED, it is 1.7V.

So, the voltage drop across the resistor is (5V-1.7V) = 3.3V.  So, we have:
$$\text{Resistor Value} = \frac{3.3\text{V}}{I}$$
So, now all we need is the target current going through resistor.  Based on Kirchhoff’s current law, we know that, for this circuit, the current through the resistor is the same as the current through the LED.  We want the LED to be running at 15mA, so we plug that in:
$$\text{Resistor Value} = \frac{3.3\text{V}}{15\times 10^{-3}\text{A}} = 220\Omega$$

So, we need a resistor that is at least $$220\Omega$$ for the circuit to be safe for the LED.

The video below shows the entire process (measuring voltage drop of LED, calculations, building circuit, etc.), and demonstrates the end result.

For another explanation of selecting resistors for LEDs, see this webpage.

Posted in Arduino, electronics, Tutorial