DevDorian
Posts: 1
Joined: Thu Aug 06, 2015 6:35 am

LED resistor data disparity

Thu Aug 06, 2015 6:55 am

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.

dpenezic
Posts: 99
Joined: Sat Dec 22, 2012 2:36 pm

Re: LED resistor data disparity

Thu Aug 06, 2015 10:02 am

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

Massi
Posts: 1691
Joined: Fri May 02, 2014 1:52 pm
Location: Italy

Re: LED resistor data disparity

Thu Aug 06, 2015 10:16 am

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 :)

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: LED resistor data disparity

Thu Aug 06, 2015 10:18 am

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.

User avatar
PeterO
Posts: 6039
Joined: Sun Jul 22, 2012 4:14 pm

Re: LED resistor data disparity

Thu Aug 06, 2015 11:37 am

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).
The correct interpretation of these figures is either:
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

User avatar
mikronauts
Posts: 2820
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: LED resistor data disparity

Thu Aug 06, 2015 3:18 pm

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

User avatar
PeterO
Posts: 6039
Joined: Sun Jul 22, 2012 4:14 pm

Re: LED resistor data disparity

Thu Aug 06, 2015 3:39 pm

mikronauts wrote:I normally use 470R for 5mA max for "standard" LED's
That isn't as helpful as it could be because you havn't told us if that is running them from 5V or 3V3.
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

User avatar
mikronauts
Posts: 2820
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: LED resistor data disparity

Thu Aug 06, 2015 6:12 pm

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:
mikronauts wrote:I normally use 470R for 5mA max for "standard" LED's
That isn't as helpful as it could be because you havn't told us if that is running them from 5V or 3V3.
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

User avatar
PeterO
Posts: 6039
Joined: Sun Jul 22, 2012 4:14 pm

Re: LED resistor data disparity

Thu Aug 06, 2015 6:52 pm

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
But the OP doesn't understand the problem, so only giving half the answer is not really that helpful !
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

User avatar
Burngate
Posts: 6401
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: LED resistor data disparity

Fri Aug 07, 2015 9:12 am

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.

User avatar
DougieLawson
Posts: 40486
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

Fri Aug 07, 2015 9:44 am

Burngate wrote:What happens if I use gas mark 3 for twice as long, and why?
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.
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.

Return to “Automation, sensing and robotics”