| layout | title | nav_order | parent | has_toc | usemathjax | comments | usetocbot | nav_exclude | search_exclude |
|---|---|---|---|---|---|---|---|---|---|
default |
L6: LEDs |
6 |
Intro to Electronics |
false |
true |
true |
true |
false |
false |
{: .no_toc }
{: .no_toc .text-delta }
- TOC {:toc}
Second only to resistors, light-emitting diodes (LEDs) are the most common electrical components used in physical computing. LEDs are power-efficient light sources not based on resistive properties and thus, are non-ohmic devices. They come in a variety of shapes and sizes (see image below). In this lesson, you will learn about diodes and how they work before diving into LEDS, the importance of current-limiting resistors, and how to use them.
Figure. LEDs range in color, size, and shape. Image from Wikipedia.
{: .fs-1 }
LEDs are a type of diode, which is an electrical component that only allows current to flow in one direction—like a one way street or a back flow valve in plumbing. In contrast to traditional lamps (incandescent light sources), LEDs have many advantages including: lower energy consumption, longer lifetimes, improved physical robustness, smaller size, and faster switching (you can turn them on and off very quickly).
For example, an incandescent bulb converts roughly 5% of its energy into visible light, the rest is lost to heat. More specifically, the typical incandescent bulb at 120V can output 16 lumens per watt vs. 60 lm/W for compact fluorescent bulbs and 150 lm/W for white LED lamps (source). Moreover, a typical incandescent bulb lasts for roughly 1,000 hours compared to 20,000-30,000 hours for LEDs.
While the basis for LED technology was discovered in 1927 (Wikipedia), it was not until the 1960s that the first visible-spectrum LEDs were demonstrated (red LEDs) and much later until they were commercially viable. Incredibly, the blue LED was not invented until the 1990s—earning co-inventors Shuji Nakamura, Hiroshi Amano, and Isamu Akasaki the 2014 Nobel Prize in Physics—and there are still LED-based breakthroughs today (e.g., high-efficiency, experimental white LEDs were demonstrated in the mid 2010s producing 303 lumens per watt of electricity). Akasaki recently passed away (in April 2021) and the New York Times has a nice obituary with an interesting history of the blue LED invention.
So, while LEDs are now pervasive, they're relatively new technology with active research.
To better understand light-emitting diodes, it's first useful to learn a bit about regular diodes and how to use them. As noted, diodes are a special type of semiconductor device that, ideally, conduct current in only one direction. See animation below.
Video. Diodes allow current to flow in only one direction—like traffic cops directing cars on a one way street. In the video above, we show how current flows through a diode from its anode lead to its cathode. But if we swap the orientation, current stops! You can play with the circuit here. {: .fs-1 }
Similar to a resistor, a diode has two leads (aka terminals or legs). Unlike resistors, they are non-ohmic and thus, do not follow Ohm's Law. And a diode is a polarized component—which means its orientation matters (as the video above highlights). The schematic symbol for a diode indicates its directional placement: the arrow faces the direction of current (and, similarly, the vertical cathode line, which is visible both on the symbol and on the device itself, should point towards -).
Figure. The diode schematic symbol and an image of a real diode, the popular 1N4001. Image made in PowerPoint. {: .fs-1 }
To use a diode, you must apply a minimum voltage, which is typically called the "on voltage" (
A typical value for
Figure. A hydraulic analogy for diodes. I cannot find the original source for this image. It originally came from Bjoern Hartmann's CS294 course at UC Berkeley (but that webpage is long gone!). {: .fs-1 }
With resistors, there is a linear relationship between voltage and current. With diodes, this current-voltage relationship is non-linear. When the applied voltage is less than
Figure. An approximate current-voltage (or I-V) graph for resistors and diodes. Notice that after the applied voltage
Typically, once
Figure. The current-voltage relationship of a diode is often simplified like the figure on the right, even though
Just like resistors, which have maximum power capacity ratings, diodes do too! For a resistor
Ideally, diodes would block any current flowing in the reverse direction; however, if a large enough "reverse" voltage is applied (e.g., -50V to -100V), then the "trap door" is overpowered and current will begin flowing in the reverse direction (again, just like a closed switch). This is called the "breakdown voltage" or "peek inverse voltage" rating in a diode's datasheet.
How would you get a "reverse voltage"? Well, the easiest way would be to hook up your voltage source backwards. Generally, for our purposes, you need not worry about this. See more here.
This is why we use the term "forward voltage" and "forward current" to distinguish against the breakdown case (with "reverse voltage" and "reverse current").
Let's analyze a 1N4001 general-purpose diode in a simple circuit with a 9V battery and a 100Ω resistor. The key here is to recognize that once our supplied voltage exceeds the "on" voltage of our diode
So, let's solve for current
Figure. In this simple circuit, we have a 9V battery, a 100Ω resistor, and a 1N4001 diode. How can we solve for current
As we've done before, when we first begin analyzing a circuit, we identify what we know. In this circuit, there are no branches. Thus, we know that current
Figure. When analyzing a circuit, the first thing to do is to observe and identify what we know. I like to label my individual nodes (colored here for clarity). Image made in Fritzing and PowerPoint.
{: .fs-1 }
Kirchhoff’s Voltage Law states that for a closed loop series path the algebraic sum of all the voltages is zero. This is due to the conservation of energy—the circuit loop is a closed conducting path, so no energy is lost.
In this case, the voltage supply of 9V plus the voltage drop
We know that
Thus,
Figure. Using Kirchhoff’s Voltage Law, we know that
Now that we know
Figure. Using Ohm's Law, we can solve for current
We can also use our trusty CircuitJS tool to simulate this circuit and check our answer. As the simulation shows below, our calculation of
Video. This video shows a CircuitJS simulation of a basic resistor-diode circuit with a 9V battery, a 100Ω resistor, and a 1N4001 diode. You can play with the circuit here. {: .fs-1 }
The last step is to check to see what our power dissipation rates are for our resistor and diode. This would help us choose an appropriate resistor and diode if we were to actually build this thing.
For the resistor:
For the diode:
Figure. As the last step, let's figure out the power demands at each electrical component. We can use the power equation:
Thus, for this circuit, we would need a bulkier resistor than the 0.25W resistors we put in our hardware kits (you can get a pack of 1,000 1 Watt resistors on Amazon for $19.99, which is about 2 cents a resistor). However, from the 1N4001 datasheet, 0.058W is well within the maximum rating of 3W, so the 1N4001 is fine.
Figure. Screenshot of the the 1N4001 datasheet.
{: .fs-1 }
In our solution, we assumed that the voltage drop over the diode (
If you care for the details, read on. Otherwise skip forward!
In fact, the I-V equation for a diode is:
Where
Whew, we finally made it back to LEDs, which are amazingly flexible, fun, and elegant electronic components (see image below). LEDs are essential to physical computing and we rely on them in many of our Intro to Arduino lessons. So, it's important that you understand how to use them.
Figure. A variety of relatively simple LED-based projects. The top row projects are built with just LEDs, resistors, and a battery. The bottom row are built with microcontrollers. From top-left: (a) Flower LED lamp built with plastic spoons by Wemyour; (b and c) Paper-based nightlights and a starry water bottle built by I Love Creativity; (d) an 8x8x8 LED cube built with Arduino Uno by Harry Le; (e) hanging LED cloud by Richard Clarkson; (f) air quality balloons by Stacey Kuznetsov and colleagues (UbiComp'11 paper, Instructables)
{: .fs-1 }
Building on our diode knowledge, we are now prepared to understand how LEDs work, how to use them, and why we need current-limiting resistors. Let's go!
LEDs are like super diodes—they function similarly but have this magical property of emitting light.
Just like other diodes, an LED has two legs and is a polarized component—it will only work in one direction. The anode + is indicated by the longer leg of the LED and the cathode - is subtly indicated by the flat side of the LED's casing (see image below). The anode must face toward the higher electric potential part of your circuit and current flows from the anode to the cathode.
Figure. The schematic symbol and labeled parts of a light-emitting diode (LED). There are two key ways to discern an LED's orientation. First, by looking for the long leg, which is the anode. If the LED legs (or leads) have been trimmed or are otherwise not visible, then you can also look at the shape of the epoxy casing, which has a subtle flat side. This flat side is pointed towards the cathode leg. Image made in PowerPoint. I don't know the source of the LED picture. {: .fs-1 }
LEDs are semiconductor devices that use electroluminscence to emit light in response to current. More specifically, when electrons pass through an LED they release energy in the form of photons. If you're curious to learn more, see this video by Today I Found Out.
Figure. An incredibly cool inside look a functioning LED by TubeTimeUS on Twitter. Slight modifications to annotations by Jon E. Froehlich.
{: .fs-1 }
Earlier, we showed a simple current-voltage graph (IV plot or IV curve) both for resistors, which follows Ohm's Law,
We can expand our IV graph for resistors to show how current linearly increases at different rates depending on the underlying resistance (literally just graphing
We can also graph the IV curve for LEDs, which again demonstrates non-linearity (remember, diodes are non-ohmic). Some important things to point out:
- First, like diodes, very little current flows through an LED until its "on" or "forward" voltage
$$V_f$$ is reached. - Second, the forward voltage
$$V_f$$ differs by the LED's color. For example, notice how blue (B) and white (W) LEDs require more$$V_f$$ than red (R) and orange (O) in the graph below.
Figure. This figure shows the IV curve for various resistor values (following
Because differently colored LEDs have unique "on" voltages
For the LEDs used to produce these IV graphs, the red LED draws 40mA at 2V while the green and blue LEDs only draw 12mA and 3mA, respectively.
Figure. Image based on LEDnique.com.
{: .fs-1 }
To evaluate the current-voltage response curve for the LEDs in our hardware kits (the Adafruit 5mm LED pack), I ran my own measurement experiments using a benchtop variable DC power supply (I have the Siglent SPD3303X-E) and my trusty multimeter.
I conducted two small experiments. First, using both a red LED and then a blue LED, I output a fixed voltage starting at 0V and incremented by 0.1V (ending at 3.2V for the red LED and 5V for the blue LED). For each step, I measured the current
Figure. IV graphs from my own experiments with the Adafruit 5mm LED pack.
{: .fs-1 }
Notably, the IV curve generally matches LEDnique.com. The red LED has a much smaller
To show how the LED brightness varies with current, I've replotted the results of the second experiment and overlaid corresponding images of my experimental setup plus the red LED output. At
Figure. The second experiment shown with images overlaid.
{: .fs-1 }
As our IV graphs demonstrate, once
We need a resistor to limit the current in the circuit. But how can we determine what resistor to use? Using the same process that we did for the diodes.
NOTE:
As an important aside, once you get used to prototyping circuits and working with LEDs, you'll often just choose a 330Ω or 470Ω resistor (with a 9V supply) or a 220Ω resistor (with a 5V supply) and start building. If the LED is too bright, just grab a bigger resistor. Too dim, smaller resistor.
You'll not go through the detailed process of picking out a perfect resistor unless it's critical to your construction (and LEDs play a key role). But we want to show you how to do it right, so read on!
To determine a current-limiting resistor, you first need to consult your LED's datasheet. The Adafruit product page for the diffused 5mm LEDs has links to five datasheets—one for each color in the pack. For this example, let's go with the red LED datasheet, which we've also copied locally just in case.
The datasheet states that the forward voltage
Figure. A screenshot of the red LED datasheet for the LEDS purchased from Adafruit.
{: .fs-1 }
Perfect, we can use this information to solve for our resistor!
Let's build a simple LED circuit with a 9V battery, a red LED, and a yet-to-be-determined resistor.
Figure. To limit the current in our LED-based circuit, we need to add a current-limiting resistor. But what value of resistance do we need? Image made in Fritzing and PowerPoint.
{: .fs-1 }
As usual, our first step is to analyze what we know about our circuit and identify the nodes. This will help us solve any open questions. There are two key things of interest: What is the voltage drop
Figure. The first step in any circuit analysis is to identify and label your knowns. Get situated! Image made in Fritzing and PowerPoint.
{: .fs-1 }
Just as we did with our regular diode circuit above, we can observe that
Figure. We can solve for
Now, we need to consult the LED datasheet again to get the forward current
Figure. Consulting the LED datasheet again for the current
Finally, we have all the information we need to solve for
Figure. Using everything we know, we can solve for resistance value
But there's just one problem: 350Ω is an unusual resistor value and it doesn't exist in your kits. You have a 330Ω resistor and a 470Ω resistor. So, which one should you use?
Well, again we can use Ohm's Law to address this question. In this case, we have a known voltage drop
For 330Ω:
For 470Ω:
The LED datasheet suggests that the maximum forward current
So, in this case, either the 330Ω or the 470Ω is probably OK (the 470Ω is, of course, a safer choice for protecting the wear on the LED).
As the final piece of analysis, we need to ensure that we are within the power dissipation limits of both the resistors and the LEDs. Recall that
For 330Ω:
For 470Ω:
In our kits, we have 0.25 watt resistors, which are capable of handling either the 0.15W (for the 330Ω circuit) or the 0.10W (for the 470Ω circuit). And the LED datasheet states that these LEDs can dissipate up to 100mW (or 0.1W), which is within 0.04W and 0.03W.
We could, of course, also use our resistor equivalance rules to combine a resistor network (in series and/or in parallel) to obtain the exact 350Ω value. In this case, it's quite simple because we can add two 10Ω to a 330Ω resistor.
We can also check our work in a circuit simulator like CircuitJS, which is good practice in general before investing time in physically building something.
**Video.** This is a screen recording of the [CircuitJS](https://www.falstad.com/circuit/circuitjs.html) simulation of the 330Ω, 350Ω, and 470Ω LED-based circuits. Play with the circuit [here](https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWcMBMcUHYMGZIA4UA2ATmIxAUgpABZsKBTAWjDACgA3EQm2ub3mEJURfEMSiSYCNgHcB4YXypCVbAE7LwGQlpQJdVbLjkKa-c1UvhT11VrA6QKW-327rKPHmeujCFC1PNgAPEGxeIgkEekxAwV1iADU2IXi3by1sAOcQABMGADMAQwBXABsAFyZyhjzwKShYdjTwGnNnTLB2-0DAgpKK6tr6iFEYSHYwsEgMSJJkYliMeMVxFPlujuzAras3Uz3nAzaOrx8XTZ7FFWvHXUvwGd47a7sNU5UnI-dJGgxIIdnjdPiD2FxWJAXvxIQlxmIJONoDIAOZmfg8WhCKRsNGwhzAmjYkS4ijEdJUBDkrGGKCcMkUhkg0QdRFSZGmKm7JTknz2diaXnaRJeY607KA+RcrRC97yIX2BVOR5C36qzIq0U7cSi4JhAx9BYIPAQOK0NbJVKEQLqnxC7X9IplKo1OoNJGTNhAA) in CircuitJS. {: .fs-1 }Once we're satisfied with our predictions (and/or simulations), we can build the LED circuit itself and measure its performance (if we are so inclined). Below, I built each of the three LED-based circuits: 330Ω, 350Ω, and 470Ω with the same red LED and measured the total voltage supplied by our 9V battery source as well as the total current
For the theoretical predictions using Ohm's Law, I plugged in measured values for the resistors and the 9V battery (which was a fresh battery supplying more than 9V).
Figure. I built each of the three LED-based circuits (330Ω, 350Ω, and 470Ω) on my breadboard and measured the total voltage drop over our circuit (yellow multimeter) as well as the total current
As you can see, our theoretical predictions were quite close to actual performance. Yay!
No. A resistor limits the current throughout a circuit loop. We know this from Ohm's Law and Kirchhoff's circuit laws.
Don't believe me? Try performing the same circuit analysis we stepped through above but with the LED before the resistor. What changes? Nothing, right?
In short: Heat. Possible spark or small fire. Burn out. Open circuit.
There are lots of fun YouTube videos of supplying too much current to LEDs and observing the effect. Here's a snippet of a good one from Afrotechmods.
**Video.** This video shows what happens when the applied voltage significantly exceeds the LED's forward voltage $$V_f$$ with no current limiting resistor. Video from [Afrotechmods](https://youtu.be/Yo6JI_bzUzo). {: .fs-1 }Still a bit confused? Try watching this video by NYU ITP's Jeff Feddersen or see the Resource links at the bottom.
For your prototyping journals, design and build two different LED-based circuits with appropriate current-limiting resistors. For this activity, do not use a breadboard (even if you already know how). Instead, just wire up things directly using alligator clips and/or by "wire wrapping". Given that we are not using breadboards, you can keep this circuit relatively simple. If you want to hook up multiple LEDs, see this tutorial by LEDnique.
For each circuit, first sketch out the idea on paper using a circuit schematic representation (some of you use sketching apps on your touchscreens; this is also fine). Then build the circuit in CircuitJS and, finally, physically build it with your actual hardware components. Include a picture of your sketch, a screenshot of your CircuitJS simulation with a direct link, and a picture of your physical construction.
To wire wrap your components, simply twist the legs together like this:
**Video.** An example of wire wrapping. {: .fs-1 }Here's an example picture of a simple LED circuit with alligator clips and wire wrapping:
Figure. An example of a simple LED circuit with a single resistor (to limit current) and multiple LEDs in series. This circuit draws ~10mA. Notice how the red LED is brightest at this amperage.
{: .fs-1 }
We'd also like you to begin experimenting with light diffusion and ideas for enclosures. For one of your LED designs, rapidly prototype a diffusive cover or case. As an example, here are simple light sabers my children and I made out of toilet paper rolls (for the hilt), paper (for the "plasma energy" blade), a 9V battery, a resistor, and some LEDs.
**Video.** Example light sabers made out of toilet paper cardboard rolls, paper, and a simple LED circuit. {: .fs-1 }-
LED Circuit Design: How to Design LED Circuits, Engineering Mindset
-
How to select resistor values for LEDs, JohnAudioTech
-
LED Basics, Afrotechmods
-
Constant current source / LED driver tutorial, Afrotechmods
-
Chapter 3: LEDs in Monk, Hacking Electronics: An Illustrated DIY Guide for Makers and Hobbyists, McGraw-Hill, 2013.
-
Chapter 22: LEDs in Platt, Make: Encyclopedia of Electronic Components Volume 2: LEDs, LCDs, audio, thyristors, digital logic, and amplification, O'Reilly, 2015.
-
Diodes and How to Use Them in Bartlett, Electronics for Beginners, Apress, 2020
-
Diodes, UIUC ECE 110





