Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ......

15
Light-Emitting Diodes (LEDs) a learn.sparkfun.com tutorial Available online at: http://sfe.io/t71 Contents The Basics How to Use Them LEDs Without Math Get the Details Types of LEDs Delving Deeper Resources and Going Further The Basics LEDs are all around us: In our phones, our cars and even our homes. Any time something electronic lights up, there’s a good chance that an LED is behind it. They come in a huge variety of sizes, shapes, and colors, but no matter what they look like they have one thing in common: they’re the bacon of electronics. They’re widely purported to make any project better and they’re often added to unlikely things (to everyone’s delight). Unlike bacon, however, they’re no good once you’ve cooked them. This guide will help you avoid any accidental LED barbecues! First things first, though. What exactly is this LED thing everyone’s talking about? LEDs (that’s “ell-ee-dees”) are a particular type of diode that convert electrical energy into light. In fact, LED stands for “Light Emitting Diode.” (It does what it says on the tin!) And this is reflected in the similarity between the diode and LED schematic symbols: Page 1 of 15

Transcript of Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ......

Page 1: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

Light-Emitting Diodes (LEDs) alearn.sparkfun.com tutorial

Available online at: http://sfe.io/t71

Contents

The BasicsHow to Use ThemLEDs Without MathGet the DetailsTypes of LEDsDelving DeeperResources and Going Further

The Basics

LEDs are all around us: In our phones, our cars and even our homes. Any time somethingelectronic lights up, there’s a good chance that an LED is behind it. They come in a huge variety ofsizes, shapes, and colors, but no matter what they look like they have one thing in common: they’rethe bacon of electronics. They’re widely purported to make any project better and they’re oftenadded to unlikely things (to everyone’s delight).

Unlike bacon, however, they’re no good once you’ve cooked them. This guide will help you avoidany accidental LED barbecues! First things first, though. What exactly is this LED thing everyone’stalking about?

LEDs (that’s “ell-ee-dees”) are a particular type of diode that convert electrical energy into light. Infact, LED stands for “Light Emitting Diode.” (It does what it says on the tin!) And this is reflected inthe similarity between the diode and LED schematic symbols:

Page 1 of 15

Page 2: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

In short, LEDs are like tiny lightbulbs. However, LEDs require a lot less power to light up bycomparison. They’re also more energy efficient, so they don’t tend to get hot like conventionallightbulbs do (unless you’re really pumping power into them). This makes them ideal for mobiledevices and other low-power applications. Don’t count them out of the high-power game, though.High-intensity LEDs have found their way into accent lighting, spotlights and even automotiveheadlights!

Are you getting the craving yet? The craving to put LEDs on everything? Good, stick with us andwe’ll show you how!

Suggested Reading

Here are some other topics that will be discussed in this tutorial. If you are unfamiliar with any ofthem, please have a look at the respective tutorial before you go any further.

What is Electricty?What is a Circuit?Voltage, Current, Resistance, and Ohm’s LawMetric Prefixes and SI UintsElectric PowerPolarityDiodes

How to Use Them

Page 2 of 15

Page 3: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

So you’ve come to the sensible conclusion that you need to put LEDs on everything. We thoughtyou’d come around. Let’s go over the rule book:

1) Polarity Matters

In electronics, polarity indicates whether a circuit component is symmetric or not. LEDs, beingdiodes, will only allow current to flow in one direction. And when there’s no current-flow, there’s nolight. Luckily, this also means that you can’t break an LED by plugging it in backwards. Rather, it justwon’t work.

The positive side of the LED is called the “anode” and is marked by having a longer “lead,” or leg.The other, negative side of the LED is called the “cathode.” Current flows from the anode to thecathode and never the opposite direction. A reversed LED can keep an entire circuit from operatingproperly by blocking current flow. So don’t freak out if adding an LED breaks your circuit. Tryflipping it around.

Page 3 of 15

Page 4: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

2) Moar Current Equals Moar Light

The brightness of an LED is directly dependent on how much current it draws. That means twothings. The first being that super bright LEDs drain batteries more quickly, because the extrabrightness comes from the extra power being used. The second is that you can control thebrightness of an LED by controlling the amount of current through it. But, setting the mood isn’t theonly reason to cut back your current.

3) There is Such a Thing as Too Much Power

If you connect an LED directly to a current source it will try to dissipate as much power as it’sallowed to draw, and, like the tragic heroes of olde, it will destroy itself. That’s why it’s important tolimit the amount of current flowing across the LED.

For this, we employ resistors. Resistors limit the flow of electrons in the circuit and protect the LEDfrom trying to draw too much current. Don’t worry, it only takes a little basic math to determine thebest resistor value to use. You can find out all about it in our resistor tutorial!

Don’t let all of this math scare you, it’s actually pretty hard to mess things up too badly. In the nextsection, we’ll go over how to make an LED circuit without getting your calculator.

LEDs Without Math

Before we talk about how to read a datasheet, let’s hook up some LEDs. After all, this is an LEDtutorial, not a reading tutorial.

It’s also not a math tutorial, so we’ll give you a few rules of thumb for getting LEDs up and running.As you’ve probably put together from the info in the last section, you’ll need a battery, a resistor andan LED. We’re using a battery as our power source, because they’re easy to find and they can’tsupply a dangerous amount of current.

The basic template for an LED circuit is pretty simple, just connect your battery, resistor and LED inseries. Like this:

Page 4 of 15

Page 5: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

A good resistor value for most LEDs is 330 Ohms. You can use the information from the last sectionto help you determine the exact value you need, but this is LEDs without math… So, start bypopping a 330 Ohm resistor into the above circuit and see what happens.

The interesting thing about resistors is that they’ll dissipate extra power as heat, so if you have aresistor that’s getting warm, you probably need to go with a smaller resistance. If your resistor is toosmall, however, you run the risk of burning out the LED! Given that you have a handful of LEDs andresistors to play with, here’s a flow chart to help you design your LED circuit by trial and error:

Page 5 of 15

Page 6: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

Another way to light up an LED is to just connect it to a coin cell battery! Since the coin cell can’tsource enough current to damage the LED, you can connect them directly together! Just push aCR2032 coin cell between the leads of the LED. The long leg of the LED should be touching theside of the battery marked with a “+”. Now you can wrap some tape around the whole thing, add amagnet, and stick it to stuff! Yay for throwies!

Page 6 of 15

Page 7: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

Of course, if you’re not getting great results with the trial and error approach, you can always getout your calculator and math it up. Don’t worry, it’s not hard to calculate the best resistor value foryour circuit. But before you can figure out the optimal resistor value, you’ll need to find the optimalcurrent for your LED. For that we’ll need to report to the datasheet…

Get the Details

Don’t go plugging any strange LEDs into your circuits, that’s just not healthy. Get to know them first.And how better than to read the datasheet.

As an example we’ll peruse the datasheet for our Basic Red 5mm LED.

LED Current

Starting at the top and making our way down, the first thing we encounter is this charming table:

Ah, yes, but what does it all mean?

The first row in the table indicates how much current your LED will be able to handle continuously.In this case, you can give it 20mA or less, and it will shine its brightest at 20mA. The second row

Page 7 of 15

Page 8: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

tells us what the maximum peak current should be for short bursts. This LED can handle shortbumps to 30mA, but you don’t want to sustain that current for too long. This datasheet is evenhelpful enough to suggest a stable current range (in the third row from the top) of 16-18mA. That’s agood target number to help you make the resistor calculations we talked about.

The following few rows are of less importance for the purposes of this tutorial. The reverse voltageis a diode property that you shouldn’t have to worry about in most cases. The power dissipation isthe amount of power in milliWatts that the LED can use before taking damage. This should workitself out as long as you keep the LED within its suggested voltage and current ratings.

LED Voltage

Let’s see what other kinds of tables they’ve put in here… Ah!

This is a useful little table! The first row tells us what the forward voltage drop across the LED willbe. Forward voltage is a term that will come up a lot when working with LEDs. This number will helpyou decide how much voltage your circuit will need to supply to the LED. If you have more than oneLED connected to a single power source, these numbers are really important because the forwardvoltage of all of the LEDs added together can’t exceed the supply voltage. We’ll talk about this morein-depth later in the delving deeper section of this tutorial.

LED Wavelength

The second row on this table tells us the wavelength of the light. Wavelength is basically a veryprecise way of explaining what color the light is. There may be some variation in this number so thetable gives us a minimum and a maximum. In this case it’s 620 to 625nm, which is just at the lowerred end of the spectrum (620 to 750nm). Again, we’ll go over wavelength in more detail in thedelving deeper section.

LED Brightness

The last row (labeled “Luminous Intensity”) is a measure of how bright the LED can get. The unitmcd, or millicandela, is a standard unit for measuring the intensity of a light source. This LED hasan maximum intensity of 200 mcd, which means it’s just bright enough to get your attention but notquite flashlight bright. At 200 mcd, this LED would make a good indicator.

Viewing Angle

Page 8 of 15

Page 9: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

Next, we’ve got this fan-shaped graph that represents the viewing angle of the LED. Different stylesof LEDs will incorporate lenses and reflectors to either concentrate most of the light in one place orspread it as widely as possible. Some LEDs are like floodlights that pump out photons in everydirection; Others are so directional that you can’t tell they’re on unless you’re looking straight atthem. To read the graph, imagine the LED is standing upright underneath it. The “spokes” on thegraph represent the viewing angle. The circular lines represent the intensity by percent of maximumintensity. This LED has a pretty tight viewing angle. You can see that looking straight down at theLED is when it’s at its brightest, because at 0 degrees the blue lines intersect with the outermostcircle. To get the 50% viewing angle, the angle at which the light is half as intense, follow the 50%circle around the graph until it intersects the blue line, then follow the nearest spoke out to read theangle. For this LED, the 50% viewing angle is about 20 degrees.

Dimensions

Finally, the mechanical drawing. This picture contains all of the measurements you’ll need toactually mount the LED in an enclosure! Notice that, like most LEDs, this one has a small flange atthe bottom. That comes in handy when you want to mount it in a panel. Simply drill a hole theperfect size for the body of the LED, and the flange will keep it from falling through!

Page 9 of 15

Page 10: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

Now that you know how to decipher the datasheet, let’s see what kind of fancy LEDs you mightencounter in the wild…

Types of LEDs

Congratulations, you know the basics! Maybe you’ve even gotten your hands on a few LEDs andstarted lighting stuff up, that’s awesome! How would you like to step up your blinky game? Let’s talkabout makin' it fancy.

Here’s the cast of characters:

RGB (Red-Green-Blue) LEDs are actually three LEDs in one! But that doesn’t mean it can onlymake three colors. Because red, green, and blue are the additive primary colors, you can controlthe intensity of each to create every color of the rainbow. Most RGB LEDs have four pins: one foreach color and a common pin. On some, the common pin is the anode, and on others, it’s thecathode.

Some LEDs are smarter than others. Take the flashing LED, for example. Inside these LEDs,there’s actually an integrated circuit that allows the LED to blink without any outside controller.Simply power it up and watch it go! These are great for projects where you want a little bit moreaction but don’t have room for control circuitry. There are even RGB flashing LEDs that cyclethrough thousands of colors!

Page 10 of 15

Page 11: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

SMD LEDs aren’t so much a specific kind of LED but a package type. As electronics get smallerand smaller, manufacturers have figured out how to cram more components in a smaller space.SMD (Surface Mount Device) parts are tiny versions of their standard counterparts. SMD LEDscome in several sizes, from fairly large to smaller than a grain of rice! Because they’re so small, andhave pads instead of legs, they’re not as easy to work with, but if you’re tight on space they mightbe just what the doctor ordered.

High-Power LEDs, from manufacturers like Luxeon and CREE, are crazy bright. Generally, an LEDis considered High-Power if it can dissipate 1 Watt or more of power. These are the fancy LEDsthat you find in really nice flashlights. Arrays of them can even be built for spotlights and automobileheadlights. Because there’s so much power being pumped through the LED, these often requireheatsinks. A heatsink is basically a chunk of heat conducting metal with lots of surface area whosejob is to transfer as much waste heat into the surrounding air as possible. High-Power LEDs cangenerate so much waste heat that they’ll damage themselves without proper cooling. Don’t let theterm “waste heat” fool you, though, these devices are still incredibly efficient compared toconventional bulbs.

Page 11 of 15

Page 12: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

There are even LEDs that emit light outside of the normal visible spectrum. You probably useInfrared LEDs every day, for instance. They’re used in things like TV remotes to send small piecesof information in the form of invisible light! On the opposite end of the spectrum you can also getUltraviolet LEDs. Ultraviolet LEDs will make certain materials fluoresce, just like a blacklight!They’re also used for disinfecting surfaces, because many bacteria are sensitive to UV radiation.

With fancy LEDs like these at your disposal, there’s no excuse for leaving anything un-illuminated.However, if your thirst for LED knowledge hasn’t been slaked, then read on, and we’ll get into thenitty-gritty on LEDs, color, and luminous intensity!

Delving Deeper

So you’ve graduated from LEDs 101 and you want more? Oh, don’t worry, we’ve got more. Let’sstart with the science behind what makes LEDs tick… err… blink. We’ve already mentioned thatLEDs are a special kind of diode, but let’s delve a little deeper into exactly what that means:

What we call an LED is really the LED and the packaging together, but the LED itself is actuallytiny! It’s a chip of semiconductor material that’s doped with impurities which creates a boundary forcharge carriers. When current flows into the semi-conductor, it jumps from one side of this boundaryto the other, releasing energy in the process. In most diodes that energy leaves as heat, but inLEDs that energy is dissipated as light!

The wavelength of light, and therefore the color, depends on the type of semiconductor materialused to make the diode. That’s because the energy band structure of semiconductors differsbetween materials, so photons are emitted with differing frequencies. Here’s a table of commonLED semiconductors by frequency:

Page 12 of 15

Page 13: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

Truncated table of semiconductor materials by color. The full table is available on the Wikipediaentry for “LED”

While the wavelength of the light depends on the band gap of the semiconductor, the intensitydepends on the amount of power being pushed through the diode. We talked about luminousintensity a little bit in a previous section, but there’s more to it than just putting a number on howbright something looks.

The unit for measuring luminous intensity is called the candela, although when you’re talking aboutthe intensity of a single LED you’re usually in the millicandela range. The interesting thing about thisunit is that it isn’t really a measure of the amount of light energy, but an actual measure of“brightness”. This is achieved by taking the power emitted in a particular direction and weightingthat number by the luminosity function of the light. The human eye is more sensitive to somewavelengths of light than others, and the luminosity function is a standardized model that accountsfor that sensitivity.

Page 13 of 15

Page 14: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

The luminous intesity of LEDs can range from the tens to the tens-of-thousands of millicandela. Thepower light on your TV is probably about 100 mcd, whereas a good flashlight might be 20,000 mcd.Looking straight into anything brighter than a few thousand millicandela can be painful; don’t try it.

Forward Voltage Drop

Oh, I also promised that we’d talk about the concept of Forward Voltage Drop. Remember when wewere looking at the datasheet and I mentioned that the Forward Voltage of all of your LEDs addedtogether can’t exceed your system voltage? This is because every component in your circuit has toshare the voltage, and the amount of voltage that every part uses together will always equal theamount that’s available. This is called Kirchhoff’s Voltage Law. So if you have a 5V power supplyand each of your LEDs have a forward voltage drop of 2.4V then you can’t power more than two ata time.

Kirchhoff’s Laws also come in handy when you want to approximate the voltage across a given partbased on the Forward Voltage of other parts. For instance, in the example I just gave there’s a 5Vsupply and 2 LEDs with a 2.4V Forward Voltage Drop each. Of course we would want to include acurrent limiting resistor, right? How would you find out the voltage across that resistor? It’s easy:

5 (System Voltage) = 2.4 (LED 1) + 2.4 (LED 2) + Resistor

5 = 4.8 + Resistor

Resistor = 5 - 4.8

Resistor = 0.2

So there is .2V across the resistor! This is a simplified example and it isn’t always this easy, buthopefully this gives you an idea of why Forward Voltage Drop is important. Using the voltagenumber you derive from Kirchhoff’s Laws you can also do things like determine the current across acomponent using Ohm’s Law. In short, you want your system voltage equal to the expectedforward voltage of your combined circuit components.

Resources and Going Further

You’ve made it! You know, like, almost everything… about LEDs. Now go forth and put LEDs onwhatever you please!

If you’d like to learn more about some LED related topics, visit these other tutorials:

LightIR CommunicationRGB Panel Hookup GuideDas Blinken Top HatLED Display Driver Hookup GuideInteractive Hanging LED Array - Create a giant LED array driven by the Arduino Pro Mini.T³: Using LEDs as Light Sensors - Using an LED as a light detector!

Page 14 of 15

Page 15: Light-Emitting Diodes (LEDs) - learn.sparkfun · PDF fileLight-Emitting Diodes (LEDs) a ... LED stands for “Light Emitting Diode.” ... it only takes a little basic math to determine

And now… a dramatic reenactment of an LED being over powered and burning itself out:

Yeah… it’s not spectacular.

learn.sparkfun.com | CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado

Page 15 of 15