I'm a beginner when it comes to electronics so please be kind. I've hit a wall on something seemingly very simple and can't google my way around it so I figure I'd throw the question out here.
I am learning how to simply blink a LED on and off using the GPIO pins. Now I can find and follow tutorials all day long but I want to know the, "why" and in this case how a resistor is chosen for a circuit.
I have found LED calculator pages online ( http://led.linear1.org/1led.wiz ) as well as formulas for calculating this myself. For this question I'll use the result I got from the calculator for simplicity.
I find that a basic 5mm green LED puts out a forward voltage of 2.0v and a rated forward current of 20ma (https://www.sparkfun.com/products/9592). As well the Raspberry Pi puts out 3.3v. Entering this into a calculator gives me a resistor choice of 68 ohms 1/8W.
My issue is that none of the tutorials use this. This one (https://projects.drogon.net/raspberry-p ... ingle-led/) uses 270 ohms.
This one (https://www.youtube.com/watch?v=IP-szuon2Bk) uses a 330 ohm.
So my question is what am I doing wrong? I get 68 ohms while everyone else is using higher ohms. I don't want to burn my components out and want to get this right.
Re: LED resistor data disparity
Hi,
your calculation is O.K. , however nothing in real world isnt black or white, mostly we use grey
.
In most case we want to get same resolute with lowest possible power consumption.
For example i mostly use 1K resistor for led that just need to light, and for "must see" LEDs I use 680E.
So basically answer on your question 68E is O.K., but same result you will get with 330E or even 680E .
Regards,
Dubravko
your calculation is O.K. , however nothing in real world isnt black or white, mostly we use grey

In most case we want to get same resolute with lowest possible power consumption.
For example i mostly use 1K resistor for led that just need to light, and for "must see" LEDs I use 680E.
So basically answer on your question 68E is O.K., but same result you will get with 330E or even 680E .
Regards,
Dubravko
Re: LED resistor data disparity
and 20mA is too much for a GPIO. With a bigger resistor you are limiting the current, your led will be less bright but your pi will be happier 

Re: LED resistor data disparity
Your calculations are correct, but there are two things to be aware of. Firstly, 20mA will give you a really bright LED, which might be too bright to be comfortable. You can probably get a pleasing glow with only 10mA.
The second point is that you shouldn't draw 20mA from a Pi GPIO. You should draw less than about 16mA per pin (or a total of 50mA for all pins). So, you can recalculate your resistor with 16mA (the maximum allowed), or provide some margin and use 10mA.
With 10mA, the calculation becomes Vs-Vf/If => 3.3-2/0.01 => 130 ohms.
If you use a higher value resistor then the current will be even lower (and the brightness will be less too, but maybe acceptable), so 270R and 330R will be fine. Even 1k should show a glimmer of light.
The second point is that you shouldn't draw 20mA from a Pi GPIO. You should draw less than about 16mA per pin (or a total of 50mA for all pins). So, you can recalculate your resistor with 16mA (the maximum allowed), or provide some margin and use 10mA.
With 10mA, the calculation becomes Vs-Vf/If => 3.3-2/0.01 => 130 ohms.
If you use a higher value resistor then the current will be even lower (and the brightness will be less too, but maybe acceptable), so 270R and 330R will be fine. Even 1k should show a glimmer of light.
Re: LED resistor data disparity
The correct interpretation of these figures is either:DevDorian wrote: I find that a basic 5mm green LED puts out a forward voltage of 2.0v and a rated forward current of 20ma (https://www.sparkfun.com/products/9592).
1) If you apply 2.0V across the led, 20ma will pass throught it
or
2) If you pass 20ma through this led it will develope 2.0V across its connections.
It does not "put out" a voltage, it is not a voltage (or current) source. The voltage measured across the led is only there while there is a curent from an external source flowing through it.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
- mikronauts
- Posts: 2821
- Joined: Sat Jan 05, 2013 7:28 pm
- Contact: Website
Re: LED resistor data disparity
I normally use 470R for 5mA max for "standard" LED's
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi
Re: LED resistor data disparity
That isn't as helpful as it could be because you havn't told us if that is running them from 5V or 3V3.mikronauts wrote:I normally use 470R for 5mA max for "standard" LED's
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
- mikronauts
- Posts: 2821
- Joined: Sat Jan 05, 2013 7:28 pm
- Contact: Website
Re: LED resistor data disparity
As the Pi I/O pins are 3v3 it was implied, the OP was asking about driving LED's from the Pi's GPIO's
PeterO wrote:That isn't as helpful as it could be because you havn't told us if that is running them from 5V or 3V3.mikronauts wrote:I normally use 470R for 5mA max for "standard" LED's
PeterO
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi
Re: LED resistor data disparity
But the OP doesn't understand the problem, so only giving half the answer is not really that helpful !mikronauts wrote:As the Pi I/O pins are 3v3 it was implied, the OP was asking about driving LED's from the Pi's GPIO's
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
- Burngate
- Posts: 6404
- Joined: Thu Sep 29, 2011 4:34 pm
- Location: Berkshire UK Tralfamadore
- Contact: Website
Re: LED resistor data disparity
I believe the OP's problem is he understands the "how"; he wants to understand the "why"
Most tutorials (and most of the posts here) are like cookery books - Gas mark 6 for half an hour. What happens if I use gas mark 3 for twice as long, and why?
What he needs from that Adafruit page is in the second line of the "Features":
Max current: 20mA
Larger resistor makes it dimmer. Smaller resistor breaks it.
Most tutorials (and most of the posts here) are like cookery books - Gas mark 6 for half an hour. What happens if I use gas mark 3 for twice as long, and why?
What he needs from that Adafruit page is in the second line of the "Features":
Max current: 20mA
Larger resistor makes it dimmer. Smaller resistor breaks it.
- DougieLawson
- Posts: 40574
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: LED resistor data disparity
You do realise that "gas mark" is an alien concept to 191 out of 192 countries in the World, especially the one that still uses °F for their oven temperatures.Burngate wrote:What happens if I use gas mark 3 for twice as long, and why?
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.