The above is what happened to an LED that was connected to a 9 volt battery without a current-limiting resistor in series. It exploded like a firecracker and the moral of the story is, WEAR EYE PROTECTION.
The lesson of the story is that you should have a current-limiting resistor in series with your LED. But resistance is a trade-off: too little and you blow out the LED, too much and you consume unnecessary power in the resistor and dim the LED.
Fortunately, calculating the proper amount of resistance for an LED is very simple algebra. It looks like this:
Let’s take a real-life example. Here are the specs on a package of LEDs:
For a 9 volt battery, our first formula becomes:
V(resistor) = V(battery) – V(led)
V(resistor) = 9 – 3.2
V(resistor) = 5.8 volts
And the value for the current-limiting resistor is:
R = V(resistor) / i(led)
R = 5.8 volts / 20 milliamps
R = 290 ohms
Any resistor above a value of 290 ohms should do fine. However, remember that resistor values sometimes have a tolerance of about ten percent, so a resistor that is labeled 300 ohms may actually be only 270 ohms. So really, why not go with something like 500 ohms minimum? You’ll have a nice safety factor and likely won’t notice the difference in brightness.
Oh wait — we also have to be concerned about not exceeding the resistor’s maximum power rating, which is typically 1/8 or 1/4 or 1/2 watt depending on the size.
For that we need this formula:
watts = voltage x current
watts = 5.8 v x 20 ma
watts = 116 milliwatts
Which is less than 1/4 watt (ie, 250 milliwatts). So a medium-sized resistor will do fine.
When all is said and done, you probably don’t want to connect a nine volt battery to an LED because you’ll be burning most of the power through that resistor without getting any light for it. As you can see from the photo, I used a 9 volt here for the sake of drama. Using a 5 volt source without a current-limiting resistor may not even burn out your LED, or will just burn it out without an explosion. But I’m not guaranteeing that either way. Did I mention, WEAR EYE PROTECTION!