Hello and welcome to our tutorial where we a look at all things LED.
A Crash Course All About LEDs (Light Emitting Diodes)
Hello guys, how are you going? My name’s Sam from Core Electronics and today we’re going to be taking a look at LEDs - that’s right! All about LEDs! Now LED stands for Light Emitting Diode and they’re used everywhere be it cars, computers, laptops space shuttles, command centres, you name it, torches, flashlights, toys - LEDs are everywhere and the reason is that they are so power efficient. They’re a very efficient way of creating light. Now traditional globes were quite power hungry because along with outputting light they also produced heat and that is wasted energy. LEDs do not produce that heat, nowhere near, and draw such a small amount of current. A standard LED will draw 20 mAh so very small devices, very cool. But we’re going to take a look today at what exactly are LEDs, how do they work, how can we use them and how can we use them without destroying them because they’re quite sensitive devices if used incorrectly.
Now there’s a working principle behind LEDs and it’s fairly straightforward. It uses a principle called ‘Electromagnetic Energy’ which is light. It’s on the electromagnetic spectrum and there’s a lot of lower level physics behind it but put simple an LED is a Diode which operates as a P-N Junction. Now a P-N Junction is a semi conductor usually silicone but it can also be other types and it is ‘Doped’ and this means that it is created specifically with either an absence or an abundance of electrons. Electrons are negatively charged particles (bear with me here just some quick physics) and those negatively charged particles are attracted to the positive side. So when there’s an absence of electrons there’s what we call holes. You can see that in the description here in the article, and those electrons are pulled towards the holes and that creates electric current flow. However the electrons obviously don’t want to go from the holes where there’s an absence of electrons towards where there’s less electrons because they’re not attracted that way, they go from positive to negative and negative to positive, not negative to negative. So that creates a bit of a one way valve, diodes are valves, they allow current to flow in one direction but not the other, that’s an LED.
Now there’s a little bit more to it but that’s a quick overview. So a traditional LED that we know is a 5 mm 10 mm 3 mm LED and it comes with 2 legs. Those are the 2 legs of an LED, one is called the Anode and the other is called the Cathode. Now the Anode can be thought of as the positive leg and the cathode as the negative leg meaning that the Anode has to have a more positive voltage than the cathode. You know if this is all getting a bit confusing you know a bit too much then check out our Analogue Electronics Crash Course Tutorial which covers a lot the basics, such as what is voltage, resistance and current. Its a bit of a more basic overview of what LEDs are and the different components. But for know lets assume you’ve read that and we’re going to press on.
So that that’s an LED and there’s a small diode inside this coloured epoxy case which contains this P-N Junction and unlike a regular diode which simply passes that current through - when a current is passed through this Junction it emits light at a certain wavelength and the electromagnetic wavelength determines its color, it’s very very cool. If it has more energy it’s going to be more blue and if it has less energy it’s going to be more red. So blue LED’s will generally use a bit more electricity however we’ll get to that in a minute. So how do we actually use the LEDs? We know a bit about them, we know how they are constructed but how do we use them? Well, there’s lots of different types of LEDs you can get digital LEDs, RGB LEDs, single color LEDs, fused LEDs, surface mount LEDs, through hole LEDs etc etc etc but the basic principle is the same. There’s 3 main specifications of the LEDs that you want to watch out for, now we’ll go through those:
First up we have the Forward Voltage, hopefully you can read my writing, it’s all in the tutorial anyway. So Forward Voltage is the number of Volts the LED requires in order to light up at its full capacity so for most LEDs the Forward Voltage is between 1.7 and 3.3 Volts. A blue LED is around 2.8V, it’s a little bit lower and a red LED will usually have a lower Forward Voltage and a blue LED will be higher. There are lots of different colours of LEDs and some of them are produced by having a different colour epoxy so it might just be white LED that has a blue epoxy around it. Blue LEDs are actually quite a recent invention while red and green were a lot easier to produce and that’s why blue LEDs are slightly more expensive. They use slightly more complex manufacturing process, whereas other LEDs are clear natural light emitted from the die is red. Cool, now we have the Forward Voltage LED and lets say is 2.8V, now you also have the Forward Current. Now the Forward Current for any LED is usually going to be between 18 and 20 mAh, so let’s assume it’s 20 mAh so 20Mah is also 0.02A. So they’re the basic specifications of our LEDs.
Now how do we us them? Now LEDs aren’t a smart device, think of LEDs as a hungry dog, sounds weird but we’ll get to it! Now a dog when it’s hungry likes dry food, he’ll eat as much dry food as he possibly can and it doesn’t know when to stop. It doesn’t know when to say Woah, that’s enough. It will eat until it is full, until it is chockers, and then it will get really really thirsty and it will drink lots of water and its belly will get as tight as a drum and may explode - no, probably not! Don’t worry! But it’s not good for it that it doesn’t know when to stop and an LED is a little bit similar in the fact that it doesn’t know how much current it should draw, how much current is healthy for it and it will just keep drawing as much current as is available and destroy itself which isn’t good. Now how do we limit this current? Well, we use Resistors and if you recall from our Analogue Crash Course (I’m assuming you’ve watched it) resistors resist the flow of current. They’re a resistive load which is Voltage, it’s only I that’s a little bit strange. Now what we can do is we can use this equation to find the resistance required by the resistor. We need to put the resistor in a series with the LED so that it is limiting that current. Now, it’s important to note that the resistor can go on either side of the LED for example we could have a schematic that looks like this:
Let’s use 5V, so plus 5 V - we go down here on our merry way down the circuit (07:34) and we have our LED, this is the schematic symbol for an LED (07:40) it’s a diode with 2 small arrows indicating it’s giving off light , current flows from this direction to this direction so that will be positive and that will be negative. Now we could put a resistor on the lower side of our LED and connect it to ground. That symbol there means ground, so there are 5V flowing through our LED and the resistor there is limiting the current and it goes there. Now we could control the 5V Pin from and Arduino and when it’s high the LED will turn on and when it’s low it would not. Or we could control the lower voltage because an LED as we said needs voltage across it to turn on. So think of voltage across an LED like a ball on a slope, if you have a really steep slope and you put a ball down it then the ball is going to roll very quickly and as you lessen the slope the ball will still roll but slowly. Now that is like voltage, voltage is the potential difference between two points, it could be thought of as the gradient of the circuit.Now if you have no volts across there or the same voltage, say 5V - 5V is Zero, 0 - 0 = 0 Theres no difference between them. (08:46) That’s like a flat slope and if you place a ball on it, it will not roll, it will not do anything and there’s no energy there for it to work, there’s no potential energy and that all voltage is, is electrical potential energy.
So we need a voltage difference, so if you turn, even if you put that ground Pin to 5V you’re not going to damage the LED, there’s no reverse voltage or reverse current going across it. It’s simply not going to light up. You can also put the LED on the other side, here, still limiting the current, still dropping the rest of the voltage in the circuit as we need it to. Now, anyway, thats where we can put the resistor but how do we calculate the resistors value? Well, it’s quite easy, we have the forward voltage required by the LED and the Forward Current. Now we know that in a circuit that if we’re using 5V and I’ve got an Arduino Board here to demonstrate which we can use the 5V output, all 5V is going to be dropped between the 5V Pin and the Ground Pin which is why it’s so dangerous to connect up a power supply directly to ground because it allows all that current flow to go through. But we’re going to use this resistor, so the Forward Volts is just 2.8V which means that across that LED another 2.2V will be dropped. SO we’ll rearrange V=IR to be R= V divided by I - that is Resistance is equal to Voltage divided by Current. So lets fill this in, R is equal to 2.2 over I. Now we know that I - the current we want flowing through our circuit is 0.02A or 20 mAh so we can do that again, R is equal to 2.2 over 0.02.Now let’s get our calculators or our phones in this case, everyone knows that you always have a phone on hand. Right, can you see that there? (10:38) we’re going to put 2.2 divided by 0.02 into our equation and it equals, you get 110 so that means that R, the Resistor that we are using in the circuit must be greater than, the minimum value it can be is 110 OHMS because if its any less it’s going to allow too much current through.
Now LEDs have a slightly non linear response curve to voltage and current which is cool because it means that even if we use a 200 OHM Resistor I doubt you will see any difference between the 110 OHM Resistor and the 200 OHM Resistor in terms of brightness. But if you use a 1K or a 10K OHM Resistor then you are really going to notice that LED dimming down so you don’t go lower than 110 but you can go higher than a 110 and tend to limit the voltage there which is pretty cool and that’s all there is to using an LED and if you have multiple LEDs in different parts of the circuits simply find out the value before and after the LED. You find out how much voltage is going to drop in that part of the circuit and the required current and you can calculate it, its really cool, no more guesstimating LED values, simply because you ‘saw it’ somewhere , you can work it out for yourself now.
So that is how we protect the LED with current limiting resistor and as I said you can control the brightness with that resistor. But what LEDs are not good at is directly correlating a change in voltage to a change in brightness because they have that strange response, so how do we do this? SO we use something called PWM, Pulse Width Modulation. We’re not going to go too far into PWM today, we’re just going to brush over how it affects LED Voltage.
So PWM is a square wave now instead of simply turning the LED on from a microcontroller or turning it off we do both, we turn it on and off really really quickly which means that things that are going fast that the human eye blurs out and averages the difference between those. So when we’re blinking an LED on and off hundreds or even thousands of times per second, it sounds really quick but it’s still really slow for a microcontroller clocking at 16 mHz, think of the gHz that modern computers run at. So it’s turning on and off very quickly and what this looks like is a sqt uare wave, so lets say we have 5V and we have 0V here - it turns on then it turns off and then it turns on again and if you looked at this with a high speed camera you would indeed see the individual flickers. But to the human eye what actually occurs is really really cool, you see the brightness of the LED correlate as a representation of the on time versus the off time. This is called Pulse Width Modulation. You’re controlling the width or the duty cycle of the pulse. Now the duty cycle, the frequency doesn’t control the brightness, the frequency only needs to be high enough to be faster than the human eye but the Pulse Width Modulation the duty cycle is what we’re going to be controlling. So if we have our ‘on time’ as - say this is the total time of one cycle.Now if we have our ‘on time’ as 75% of that and our ‘off time’ as 25% the LED is going to show up and that goes on and on and on. The LED is going to display at approximately 75% brightness, likewise if here is our total cycle and we have it high for 25% of the time and low for 25% of the time and then on and on, it will appear at 25% brightness because the human eye is averaging those changes. It says,Oh well its off less time that it is on Ahhh, it’s about that bright, fantastic. (not really that simple but that’s my explanation!) So that’s how we can use Pulse Width Modulation to control the brightness of an LED.
Now what’s that I hear you ask…. Multiple LEDs in a circuit? No…Yes! Now, there’s a little bit of a misunderstanding with this and it just comes down to the lack of understanding between the basic type of circuitry - that is serial or parallel. Now in Series you might of heard of Serial Data before? That refers to the fact that information is sent one bit after the other in serial, there’s not multiple lines, it’s not running in parallel channels, its just one line. The same can be said of LEDs, you might have had a set of Xmas lights, Xmas lights are a great example, everyone has that set of Xmas lights where once it was working and now it’s not. Perhaps your Dad in all of his infinite wisdom went around checking each individual LED, trying to see which ones work and that’s because the LEDs were connected in Series. You had one LED going into another LED (excuse the lack of arrows or current limiting resistors) into one LED and so on and so forth and that was your chain of LEDs. Now if one LED breaks or is damaged for some reason it’s going to not allow the current to flow through that and suddenly you’ve got a broken circuit. Every LED will go out which sucks. So now the modern Xmas lights use parallel circuits and what this means is that if this is your 5V and this is your 0V line or Ground - they’re the power lines - you’ve got an LED going between 5V and Ground with its resistor there and you have another one in parallel to it which is very cool. Now this allows as much current to flow through each individual circuit branch as the Resistor will allow and it allows each LED to have its own path. So, if one goes down that LED still has a path from 5V to Ground. Now the big reason, along with the testing of a broken LED is that with LEDs in series you know how theres a voltage drop across the LEDs so with the blue LED we just used, it was about 2.8V and that means, say you start off with 12V, this LED has 12V to work with and it drops 2.8V, the next LED gets the remainder of that so it doesn’t get all 12V, it only gets 9.2V and so on and so forth until the LEDs no longer have any voltage left to work with and this appears as one LED will be brighter then slightly less bright, slightly less bright and dimmer and dimmer and dimmer which isn’t the ideal effect. In Parallel they get even share of the voltage trail and they all glow at uniform brightness so however the resistor is set. Really cool, so if you’re wanting to use LEDs, multiple LEDs in a circuit that’s how you go about it, the Resistors are calculated the exact same way so no fear.
Now, the last thing we’re going to cover is two different unique types of LEDs and these are RGB LEDs which we mentioned earlier and Digital LEDs. Now Ive got an RGB LED here and I’m not sure how well you can see that but it’s a single LED package and you’ll notice that there’s actually 4 legs coming off it and that means that inside that epoxy package there’s 3 individual dies of the diodes inside that, each with it’s own controller so what this would look like is you would have 1 LED, 2 LEDs, 3 LEDs, one would be red, one would be green and the other would be blue RGB! and these would have individual pins. Now you can get common Cathode RGB LEDs which means that the Cathode Pins here, the negative Pins all connect up and you would connect that with ground perhaps with a resistor on the other side so you connect that to ground and have your control pins here, individual resistors and away you go. You can also have common Anode LEDs which are simply the opposite, now that’s pretty cool. So that’s RGB LEDs and the other type is Digital LEDs, now these are incredibly cool, you might know that these as Neopixels or Dotstars - thats Adafruits brand names for those, and they’re just a digital chip on board which can accept serial data and then control the LEDs and the cool thing about those is that you can control hundreds of the things with just 2 control IDES for all of the LEDs, very very cool. There’s individual tutorials on both Neopixels and Dotstar so check those out,we go into more detail there.
That is a quick run down all about LEDs, hope you learnt something new today guys and you can take these principles and get a better understanding of whats going on in your circuit rather than just guessing at what is going on and not really understanding the fundamentals behind it. It’s not that complicated, have a go, practice some equations on your own. I’m Sam, I hope you learnt something new today guys and I will see you next time :-)
Makers love reviews as much as you do, please follow this link to review the products you have purchased.