This is it, the most important information a modern electronics engineer needs. How to hook up an LED (or 20) to your project.
Firstly, what is an LED?
It is a component consisting of a semiconducting material that only allows current to pass in one direction... An electronic check valve. Here, these are called Diodes, and this particular type is called a Light Emitting Diode, because when it starts to conduct, it gives off light.
The fact it only works one way means it is polar and has a definite positive (anode) and negative (cathode).
LEDs are generally used in place of indicator lamps or neon bulbs because, well, they’re generally better. They last longer, they don’t need silly voltages or use lots of power. Plus, you can now get them in just about any colour you can think of.
Enough of the sales pitch, to get one working, we will need a few bits of information about the LED you want to light up. If you have bought your LEDs online, you should be able to download the datasheet directly, if you bought them from your local LED vendor, they should be able to print one out for you... probably... or at least write it on the back of a Greggs wrapper.
What we are looking for is the forward voltage (Vf) and the maximum current (Imax). It should be in the 'electrical charactaristics' section of the datasheet, and online vendors very often put it in the main description of the listing. If the local vendor was not forthcoming in printing a datasheet, or if they are ones you have salvaged, there is hope.
If the led has a coloured lens - assume the Vf to be 2v and Imax to be 10mA
If the LED has a clear lens - assume the Vf to be around 2.5v and Imax to be 10mA.
If you have a multimeter, you can set it to diode mode, attach the red probe to the long leg (anode) of the LED and the black probe to the short leg (cathode), and by the power of modern technology, it will measure the forward voltage for you.
Assume the Imax to be about 10mA though. may end up a little dimmer over all, but better that than being very bright for a tenth of a second, then taking a swift trip to the parts bin in the sky.
Now we have that, for the sake of example lets say our Vf is 1.9v and our Imax is 20mA, we can now figure out what else we need to light up this LED.
Looking at the circuit diagram below, we can see our battery, then from the + terminal a resistor inventively labelled ‘R’ (used to limit the current to the LED), then the LED itself, then it loops back to the battery’s - terminal.
We know that 1.9v is dropped across the LED, and 9v is dropped across the full circuit, so we can figure that the remaining voltage, dropped across the resistor is 7.1v (the 9v supply minus the 1.9v dropped across the LED). With this in hand, we can figure out the value of resistor we need, and for that, we need Ohm’s Law.
With any two values, you can figure out the third. By covering up the one you want, the remaining two show you the calculation, if they are side by side, you multiply them, and if one is on top of the other, you divide the one on top by the one on the bottom.
We need ‘R’ so we cover it, leaving V on top of I so we now know that R=V/I.
(Ohm’s law is super important all throughout electronics, it crops up everywhere, so it’s good to have it in the toolkit)
We have already figured out that V is 7.1v.
The maximum current for our LED is 20mA, but to extend the life of the LED and the battery, we'll halve that to 10mA (equal to 0.010 Amps).
We can now fill in the formula.
It shows our ideal resistor value would be 710-Ohms.
Lets round that up to the next standard value of 820-Ohms to save a couple of quid.
As this is a series circuit (everything forms a single file line), the current remains constant throughout, so the 10ish mA drawn to drop the 7.1v through the resistor causes 10ish mA to be drawn by the 1.9v dropped across the LED.
The higher the mA, the brighter the LED.
Thats all well and good, but I want MOOOORE LEDs. Lets say 3. We could just make 3 of the circuits above, and that is a pretty good way of doing it, it keeps the load per resistor down, but it takes one resistor per LED which can get take up a lot of room for large scale circuits.
The other way would be to put our three LEDs in Parallel. Where all of the positive legs are connected together, and so to all of the negative legs. Something like this:
This now only uses one resistor for all three LEDs, but if we were to use the same value, they would be very dim.
We can calculate the new value by taking into account that we wish to drive each of the three LEDs at 10mA, totalling 30mA. Everything else remains the same, so if we plumb that in, we get an ideal resistor value of 237-Ohms. Rounded up to the nearest standard value, it would be 330 Ohms.
Sadly, this is not as fine and dandy as it would seem. with the extra power drawn, we need to be carefull that we do not exceed the power rating of our resistor.
We can figure out the power drawn by multiplying the voltage dropped over the component (7.1v was dropped over the resistor) by the current of the series elements (22mA or 0.022A after rounding to the 330-ohm resistor).
This tells us the total power dissapated by just the resistor is 0.16W, which would be within the rating for a 0.25W resistor, but the closer to the rated level you run, the shorter the lifespan of the component is likely to be.
This is nice to know, but on the small scale level, it's worth just putting in a resistor for each LED, it's a little more work, but you know you'll be well within the rating of your components.
Switching
So far, we have just had it constantly on from the power supply, but what if we want to control when the LED is on or off. The main ways of doing that are:
Using a physical switch
Using a microcontroller pin
Using a switching transistor
The first two are easy, a physical switch is just that, just like a home light switch. If using a microcontroller, just use the desired pin in place of the positive battery connection and the ground pin as the negative. when the pin is set high, the led will light, when it is set low, the led will go off.
Care must be taken not to overload the pin with excess current draw. The total current draw on the pin (what you're giving the LEDs in total) must not exceed what it is rated to supply (usually about 100mA)
That doesn't mean you are limited to sub 100mA loads, you will just need to use the third method, using a switching transistor.
I wont go into the gory details of how transistors work, that can be saved for another time, but we'll cover the basics.
We will be using a general purpose, cheap-and-cheerfull NPN type for this, like the 2n2222. It has three pins; a collector, a base and an emitter (check the proper datasheet to see which is which as it changes between flavours). We will want to connect the emitter to ground. the base is then connected to the microcontroller pin, or whatever voltage source you are triggering it with, via a resistor. The value of the resistor is not massively important for simple switching. whatever you have lots of between 1K and 10K.
The current limiting resistor and LED then join the collector to the main voltage rail. The resistor value is determined in exactly the same way as above. The negative leg (cathode) joins to the collector and hey presto, you have a load switched via a transistor.
As the microcontroller pin goes high, the transistor switches on, and so too your LED.
That just about covers everything to get you going with putting LEDs in your projects. On a practical note, it is usual to forego the current limiting resistor calculations and just put in a 1K-Ohm resistor. This gives a pretty good brightness and will keep you under 10mA up to 12v (depending on the forward voltage of the LED), but it is good practice to get to know how to do these, as electronics invariably revolves around Ohm's Law.
Let me know if I've missed anything
Happy soldering,
R
Header image by
Firstly, what is an LED?
It is a component consisting of a semiconducting material that only allows current to pass in one direction... An electronic check valve. Here, these are called Diodes, and this particular type is called a Light Emitting Diode, because when it starts to conduct, it gives off light.
The fact it only works one way means it is polar and has a definite positive (anode) and negative (cathode).
LEDs are generally used in place of indicator lamps or neon bulbs because, well, they’re generally better. They last longer, they don’t need silly voltages or use lots of power. Plus, you can now get them in just about any colour you can think of.
Enough of the sales pitch, to get one working, we will need a few bits of information about the LED you want to light up. If you have bought your LEDs online, you should be able to download the datasheet directly, if you bought them from your local LED vendor, they should be able to print one out for you... probably... or at least write it on the back of a Greggs wrapper.
What we are looking for is the forward voltage (Vf) and the maximum current (Imax). It should be in the 'electrical charactaristics' section of the datasheet, and online vendors very often put it in the main description of the listing. If the local vendor was not forthcoming in printing a datasheet, or if they are ones you have salvaged, there is hope.
If the led has a coloured lens - assume the Vf to be 2v and Imax to be 10mA
If the LED has a clear lens - assume the Vf to be around 2.5v and Imax to be 10mA.
If you have a multimeter, you can set it to diode mode, attach the red probe to the long leg (anode) of the LED and the black probe to the short leg (cathode), and by the power of modern technology, it will measure the forward voltage for you.
Assume the Imax to be about 10mA though. may end up a little dimmer over all, but better that than being very bright for a tenth of a second, then taking a swift trip to the parts bin in the sky.
Now we have that, for the sake of example lets say our Vf is 1.9v and our Imax is 20mA, we can now figure out what else we need to light up this LED.
Looking at the circuit diagram below, we can see our battery, then from the + terminal a resistor inventively labelled ‘R’ (used to limit the current to the LED), then the LED itself, then it loops back to the battery’s - terminal.
We know that 1.9v is dropped across the LED, and 9v is dropped across the full circuit, so we can figure that the remaining voltage, dropped across the resistor is 7.1v (the 9v supply minus the 1.9v dropped across the LED). With this in hand, we can figure out the value of resistor we need, and for that, we need Ohm’s Law.
With any two values, you can figure out the third. By covering up the one you want, the remaining two show you the calculation, if they are side by side, you multiply them, and if one is on top of the other, you divide the one on top by the one on the bottom.
We need ‘R’ so we cover it, leaving V on top of I so we now know that R=V/I.
(Ohm’s law is super important all throughout electronics, it crops up everywhere, so it’s good to have it in the toolkit)
We have already figured out that V is 7.1v.
The maximum current for our LED is 20mA, but to extend the life of the LED and the battery, we'll halve that to 10mA (equal to 0.010 Amps).
We can now fill in the formula.
It shows our ideal resistor value would be 710-Ohms.
Lets round that up to the next standard value of 820-Ohms to save a couple of quid.
As this is a series circuit (everything forms a single file line), the current remains constant throughout, so the 10ish mA drawn to drop the 7.1v through the resistor causes 10ish mA to be drawn by the 1.9v dropped across the LED.
The higher the mA, the brighter the LED.
Thats all well and good, but I want MOOOORE LEDs. Lets say 3. We could just make 3 of the circuits above, and that is a pretty good way of doing it, it keeps the load per resistor down, but it takes one resistor per LED which can get take up a lot of room for large scale circuits.
The other way would be to put our three LEDs in Parallel. Where all of the positive legs are connected together, and so to all of the negative legs. Something like this:
This now only uses one resistor for all three LEDs, but if we were to use the same value, they would be very dim.
We can calculate the new value by taking into account that we wish to drive each of the three LEDs at 10mA, totalling 30mA. Everything else remains the same, so if we plumb that in, we get an ideal resistor value of 237-Ohms. Rounded up to the nearest standard value, it would be 330 Ohms.
Sadly, this is not as fine and dandy as it would seem. with the extra power drawn, we need to be carefull that we do not exceed the power rating of our resistor.
We can figure out the power drawn by multiplying the voltage dropped over the component (7.1v was dropped over the resistor) by the current of the series elements (22mA or 0.022A after rounding to the 330-ohm resistor).
This tells us the total power dissapated by just the resistor is 0.16W, which would be within the rating for a 0.25W resistor, but the closer to the rated level you run, the shorter the lifespan of the component is likely to be.
This is nice to know, but on the small scale level, it's worth just putting in a resistor for each LED, it's a little more work, but you know you'll be well within the rating of your components.
Switching
So far, we have just had it constantly on from the power supply, but what if we want to control when the LED is on or off. The main ways of doing that are:
Using a physical switch
Using a microcontroller pin
Using a switching transistor
The first two are easy, a physical switch is just that, just like a home light switch. If using a microcontroller, just use the desired pin in place of the positive battery connection and the ground pin as the negative. when the pin is set high, the led will light, when it is set low, the led will go off.
Care must be taken not to overload the pin with excess current draw. The total current draw on the pin (what you're giving the LEDs in total) must not exceed what it is rated to supply (usually about 100mA)
That doesn't mean you are limited to sub 100mA loads, you will just need to use the third method, using a switching transistor.
I wont go into the gory details of how transistors work, that can be saved for another time, but we'll cover the basics.
We will be using a general purpose, cheap-and-cheerfull NPN type for this, like the 2n2222. It has three pins; a collector, a base and an emitter (check the proper datasheet to see which is which as it changes between flavours). We will want to connect the emitter to ground. the base is then connected to the microcontroller pin, or whatever voltage source you are triggering it with, via a resistor. The value of the resistor is not massively important for simple switching. whatever you have lots of between 1K and 10K.
The current limiting resistor and LED then join the collector to the main voltage rail. The resistor value is determined in exactly the same way as above. The negative leg (cathode) joins to the collector and hey presto, you have a load switched via a transistor.
As the microcontroller pin goes high, the transistor switches on, and so too your LED.
That just about covers everything to get you going with putting LEDs in your projects. On a practical note, it is usual to forego the current limiting resistor calculations and just put in a 1K-Ohm resistor. This gives a pretty good brightness and will keep you under 10mA up to 12v (depending on the forward voltage of the LED), but it is good practice to get to know how to do these, as electronics invariably revolves around Ohm's Law.
Let me know if I've missed anything
Happy soldering,
R
Header image by
Jason Dent







Live Casino and Games - Live Casino and Games at Betway
ReplyDeleteWelcome 온카지노 to the Betway online casino, home betway login to the best live slots and latest casino games, including blackjack, roulette, 퍼스트카지노
Wynn casino in Las Vegas to reopen early next week
ReplyDeleteThe 의정부 출장마사지 Wynn 아산 출장안마 casino in Las 광양 출장안마 Vegas will 경상남도 출장안마 reopen at 5 p.m. on 의정부 출장마사지 Friday, Dec. 19, pending an investigation by the Nevada Gaming Control Board. Wynn
3명이서 하는데, 한 사람이 딜러가 되어 네 목의 40장 투전목을 섞어서 2명이서 1장씩 나눠준다. 프랑스 중세 시기 때에, 도박을 즐기던 세금 징수원들을 '농부'라고 부르고, 금고를 '농장'이라고 은유적으로 바카라 게임 표현한 것에서 유래했다. 그 외에도 blackjack 이라고 치면 많은 무료앱 및 블랙잭 전략 관련 앱들이 나온다.
ReplyDelete