220 OHM or 330 OHM resistor between LED & 3.3V on Pi

1,870 views
Skip to first unread message

Don Davis

unread,
Aug 2, 2014, 3:15:39 PM8/2/14
to 10BitWorks
Connecting LEDs to the Pi, I'd like to keep the LED as bright as
possible (and it should last). Can I use 220 ohm resistors or would I be
better served with 330 ohm resistors? [I see a recommended range is
between 270 and 330.]


Joshua Snyder

unread,
Aug 2, 2014, 4:50:48 PM8/2/14
to sa-hack...@googlegroups.com
What is the current rating on the Led?  That will drive which resistor you should us.

Don Davis

unread,
Aug 2, 2014, 5:05:27 PM8/2/14
to sa-hack...@googlegroups.com
Using this calculator http://led.linear1.org/1led.wiz for this LED
https://www.adafruit.com/products/387, it tells me 18 Ohms - but that
doesn't seem right.

Not sure which forward amperage to use e.g. 20 ma or 100 ma (listed
under the LED specs) or 200ma (estimated Pi pin current).

Similarly interested in https://www.adafruit.com/products/300
> --
> You received this message because you are subscribed to the Google
> Groups "10BitWorks" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sa-hackerspac...@googlegroups.com
> <mailto:sa-hackerspac...@googlegroups.com>.
> To post to this group, send email to sa-hack...@googlegroups.com
> <mailto:sa-hack...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com
> <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com?utm_medium=email&utm_source=footer>.

Joshua Snyder

unread,
Aug 2, 2014, 8:06:12 PM8/2/14
to sa-hack...@googlegroups.com

You are actually correct, to get 100ma you would use a 18.9 ohm resister.  The problem you are going to have is that you can't source 100ma of current from the Pi's GPIO pin.  You can source up to a max of 16ma.  So what I have done in the past is use the GPIO line to active the LED.  The current to drive the LED does not come from the PI.  Basically the when you drive the GPIO High that current activates NPN transistor allowing the current to flow from the 3.3 source to ground and through the LED.  See the schematic below.  You still need the R1 resistor to keep the current flow to 100ma.  And you put a large resistor on the GPIO line to keep the current flow safely below the 16ma limit on the PI's GPIO line.




On Saturday, August 2, 2014 4:05:27 PM UTC-5, gnu_don wrote:
Using this calculator http://led.linear1.org/1led.wiz for this LED
https://www.adafruit.com/products/387, it tells me 18 Ohms - but that
doesn't seem right.

Not sure which forward amperage to use e.g. 20 ma or 100 ma (listed
under the LED specs) or 200ma (estimated Pi pin current).

Similarly interested in https://www.adafruit.com/products/300



On 08/02/2014 03:50 PM, Joshua Snyder via 10BitWorks wrote:
> What is the current rating on the Led?  That will drive which resistor
> you should us.
>
> On Saturday, August 2, 2014 2:15:39 PM UTC-5, gnu_don wrote:
>
>     Connecting LEDs to the Pi, I'd like to keep the LED as bright as
>     possible (and it should last). Can I use 220 ohm resistors or would
>     I be
>     better served with 330 ohm resistors? [I see a recommended range is
>     between 270 and 330.]
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "10BitWorks" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sa-hackerspac...@googlegroups.com

Don Davis

unread,
Aug 2, 2014, 8:54:56 PM8/2/14
to sa-hack...@googlegroups.com
What happens when simply using a 220 ohm resistor as in this example:
https://projects.drogon.net/raspberry-pi/gpio-examples/tux-crossing/gpio-examples-1-a-single-led/
?
[i.e. no NPN and larger resistor]




On 08/02/2014 07:06 PM, Joshua Snyder via 10BitWorks wrote:
> You are actually correct, to get 100ma you would use a 18.9 ohm
> resister. The problem you are going to have is that you can't source
> 100ma of current from the Pi's GPIO pin. You can source up to a max of
> 16ma. So what I have done in the past is use the GPIO line to active
> the LED. The current to drive the LED does not come from the PI.
> Basically the when you drive the GPIO High that current activates NPN
> transistor allowing the current to flow from the 3.3 source to ground
> and through the LED. See the schematic below. You still need the R1
> resistor to keep the current flow to 100ma. And you put a large
> resistor on the GPIO line to keep the current flow safely below the 16ma
> limit on the PI's GPIO line.
>
>
> <https://lh5.googleusercontent.com/-V1IXiq3TTvY/U912aWpCBxI/AAAAAAAAAKQ/aaGIM9Vtj4A/s1600/Screenshot+2014-08-02+18.30.07.png>
>
>
>
> On Saturday, August 2, 2014 4:05:27 PM UTC-5, gnu_don wrote:
>
> Using this calculator http://led.linear1.org/1led.wiz
> <http://led.linear1.org/1led.wiz> for this LED
> https://www.adafruit.com/products/387
> <https://www.adafruit.com/products/387>, it tells me 18 Ohms - but that
> doesn't seem right.
>
> Not sure which forward amperage to use e.g. 20 ma or 100 ma (listed
> under the LED specs) or 200ma (estimated Pi pin current).
>
> Similarly interested in https://www.adafruit.com/products/300
> <https://www.adafruit.com/products/300>
>
>
>
> On 08/02/2014 03:50 PM, Joshua Snyder via 10BitWorks wrote:
> > What is the current rating on the Led? That will drive which
> resistor
> > you should us.
> >
> > On Saturday, August 2, 2014 2:15:39 PM UTC-5, gnu_don wrote:
> >
> > Connecting LEDs to the Pi, I'd like to keep the LED as bright as
> > possible (and it should last). Can I use 220 ohm resistors or
> would
> > I be
> > better served with 330 ohm resistors? [I see a recommended
> range is
> > between 270 and 330.]
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "10BitWorks" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to sa-hackerspac...@googlegroups.com <javascript:>
> > <mailto:sa-hackerspac...@googlegroups.com <javascript:>>.
> > To post to this group, send email to sa-hack...@googlegroups.com
> <javascript:>
> > <mailto:sa-hack...@googlegroups.com <javascript:>>.
> <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "10BitWorks" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sa-hackerspac...@googlegroups.com
> <mailto:sa-hackerspac...@googlegroups.com>.
> To post to this group, send email to sa-hack...@googlegroups.com
> <mailto:sa-hack...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sa-hackerspace/cb04941a-9a58-4a77-89d8-2fa0b61cc19e%40googlegroups.com
> <https://groups.google.com/d/msgid/sa-hackerspace/cb04941a-9a58-4a77-89d8-2fa0b61cc19e%40googlegroups.com?utm_medium=email&utm_source=footer>.

Joshua Snyder

unread,
Aug 3, 2014, 1:06:02 AM8/3/14
to sa-hack...@googlegroups.com
Led would light up.  But it would be far from full brightness.  

In detail, assuming that the Led has a forward voltage of 1.4 volt.  That would give you a voltage drop of 1.9 volts over the resister.  Using Ohms law, that gives you a current of 8.63mA for a 220 Ohm resister or 7mA with a 270 Ohm resister from the example above.  We can ignore the very small resistance from the LED itself.  

In both cases, your led would light up just fine.  It would just be at about 1/10 of it's maximum rated brightness.   Also, your Ras-PI is very happy as it's only putting out about half of it's maximum rated current on the GPIO pin.  

The whole reason the resister is in the circuit is to protect stuff from burning up.  The reason the example you linked says to use between a 220-330 is they want to keep the current from going over the recommended 16mA per GPIO.  

But since you want maximum brightness, you need to get 100mA through this LED.   What I described with the transistor allows you to do that, the current coming out of the Ras-Pi is low, only 3.3mA.  But the current flow through the LED would be 100mA.

If you want, just by-pass the PI and wire up the LED with a 3.3 Volt source and try it with the 270 Ohm and 19 Ohm resister.  Since this LED is rated for that current it will be fine in both cases.  But the smaller resister will much brighter.  

lol, I just realized, this is a IR LED.  You won't be able to see the difference.  Hmmm, I guess I outlined how to do the calculations for the Green LED... Hmmm, the Green LED has a forward voltage range of 3.2-3.8 volts, Depending on the LED you might not be able to over come the Forward voltage from the 3.3 volt GPIO pin on the PI. 

Let me know if you don't understand something.   p.s. I noticed that forgot to include the 0.4 voltage drop over the transistor example that I gave you before.  
>     > <mailto:sa-hackerspace+unsub...@googlegroups.com <javascript:>>.
>     > To post to this group, send email to sa-hack...@googlegroups.com
>     <javascript:>
>     > <mailto:sa-hack...@googlegroups.com <javascript:>>.
>     > To view this discussion on the web visit
>     >
>     https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com
>     <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com>
>
>     >
>     <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "10BitWorks" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sa-hackerspac...@googlegroups.com

Don Davis

unread,
Aug 3, 2014, 6:49:56 AM8/3/14
to 10BitWorks on behalf of Joshua Snyder
What if I'm powering the ir led through the 3.3 v?

Sent from a mobile device.
To unsubscribe from this group and stop receiving emails from it, send an email to sa-hackerspac...@googlegroups.com.
To post to this group, send email to sa-hack...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sa-hackerspace/5862c1ec-0b59-4065-9075-b2a667a9fbc9%40googlegroups.com.

Joshua Snyder

unread,
Aug 3, 2014, 12:02:01 PM8/3/14
to sa-hack...@googlegroups.com
The 3.3volt power bus from the Pi is able to put out about 250mA of current which is more than fine for one or two of these IR LED's. 

If you want to control the LED, you would still need something like I described yesterday with a transistor switching the LED on or off.

Also, given that your Green LED has a forward Voltage range of 3.2-3.8 volts, you will likely need to use the 5volt power coming off of the Pi to power that LED.  You will have to change the resister values on that circuit since those LED's want 20mA and you will be working with 5volt not 3.3 power input.  But otherwise the math is exactly the same.  Don't forget to include the 0.4 volt drop over transistor like I did in my first example.   

On Sunday, August 3, 2014 5:49:56 AM UTC-5, gnu_don wrote:
What if I'm powering the ir led through the 3.3 v?

Sent from a mobile device.

Don Davis

unread,
Aug 3, 2014, 1:03:22 PM8/3/14
to sa-hack...@googlegroups.com
Thank you. I'm powering one IR LED continuously, so that's fine. For
what I'm doing now, I think I'd rather just keep the green LEDs at
one/10th power than mess with adding another little board into the mix
right now (I don't know that the NPN and extra resistor will fit on the
current prototyping boards). Planning the next iteration, Should I use
1k & 56 ohm resistors then with the 5v & gpio setup? Same npn?
I'm a little hazy on the math as I'm not exactly sure what I'm adding
where and how it all figures in with the npn & the gpio.

Will I be switching the GPIO to high to activate the NPN?

I've had problems using NPNs in the past.

So R1 (~56ohm?) is on the ground side of the LED? Won't 5v (or 3.3v)
coming in the + side of the LED fry it?

Any recommendations for a button size proto-board?



On 08/03/2014 11:02 AM, Joshua Snyder via 10BitWorks wrote:
> The 3.3volt power bus from the Pi is able to put out about 250mA of
> current which is more than fine for one or two of these IR LED's.
>
> If you want to control the LED, you would still need something like I
> described yesterday with a transistor switching the LED on or off.
>
> Also, given that your Green LED has a forward Voltage range of 3.2-3.8
> volts, you will likely need to use the 5volt power coming off of the Pi
> to power that LED. You will have to change the resister values on that
> circuit since those LED's want 20mA and you will be working with 5volt
> not 3.3 power input. But otherwise the math is exactly the same. Don't
> forget to include the 0.4 volt drop over transistor like I did in my
> first example.
>
> On Sunday, August 3, 2014 5:49:56 AM UTC-5, gnu_don wrote:
>
> What if I'm powering the ir led through the 3.3 v?
>
> Sent from a mobile device.
>
> On Aug 3, 2014, at 12:06 AM, Joshua Snyder via 10BitWorks
> <sa-hackerspace+noreply-APn2wQe2P...@googlegroups.com
>> > > <mailto:sa-hackerspac...@googlegroups.com
>> <javascript:>>.
>> > > To post to this group, send email to
>> sa-hack...@googlegroups.com
>> > <javascript:>
>> > > <mailto:sa-hack...@googlegroups.com <javascript:>>.
>> > > To view this discussion on the web visit
>> > >
>> >
>> https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com
>> <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com>
>>
>> >
>> <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com
>> <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com>>
>>
>> >
>> > >
>> >
>> <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com?utm_medium=email&utm_source=footer
>> <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com?utm_medium=email&utm_source=footer>
>>
>> >
>> <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com?utm_medium=email&utm_source=footer
>> <https://groups.google.com/d/msgid/sa-hackerspace/73b2c45f-311b-4707-8804-670e2a1fcb9c%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
>>
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the
>> Google
>> > Groups "10BitWorks" group.
>> > To unsubscribe from this group and stop receiving emails
>> from it, send
>> > an email to sa-hackerspac...@googlegroups.com
>> > <mailto:sa-hackerspac...@googlegroups.com>.
>> <https://groups.google.com/d/msgid/sa-hackerspace/cb04941a-9a58-4a77-89d8-2fa0b61cc19e%40googlegroups.com?utm_medium=email&utm_source=footer
>> <https://groups.google.com/d/msgid/sa-hackerspace/cb04941a-9a58-4a77-89d8-2fa0b61cc19e%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "10BitWorks" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to sa-hackerspac...@googlegroups.com <javascript:>.
>> To post to this group, send email to sa-hack...@googlegroups.com
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sa-hackerspace/5862c1ec-0b59-4065-9075-b2a667a9fbc9%40googlegroups.com
>> <https://groups.google.com/d/msgid/sa-hackerspace/5862c1ec-0b59-4065-9075-b2a667a9fbc9%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "10BitWorks" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sa-hackerspac...@googlegroups.com
> <mailto:sa-hackerspac...@googlegroups.com>.
> To post to this group, send email to sa-hack...@googlegroups.com
> <mailto:sa-hack...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sa-hackerspace/80c40809-1683-45d0-80a7-2c34ebe48df8%40googlegroups.com
> <https://groups.google.com/d/msgid/sa-hackerspace/80c40809-1683-45d0-80a7-2c34ebe48df8%40googlegroups.com?utm_medium=email&utm_source=footer>.

Joshua Snyder

unread,
Aug 3, 2014, 11:15:47 PM8/3/14
to sa-hack...@googlegroups.com
It's a rather wide forward voltage range on the Green LED.  But if you have 3.8 volt forward voltage(worst case). I come up with a 40 ohm R1 resistor. 

That's 3.8 volts over the LED, 0.4 over the transistor leaving you with 0.8 volts to drop over R1.  To get 20mA you then need a 40 ohm resistor. 

I just picked this specific NPN  transistor because I have a few of them here.  You can substitute for what you have as long as it meets the current requirements, which shouldn't be a problem. 

Yes you will switch the GPIO High to activate the LED. 

You won't have any problems with the +5volt feeding directly into the LED.  It's not the voltage that is the problems burning out LED's, it's current.  Remember the other side of the LED you will still be at +1.2 volts.  The voltage drop will always be the same over the LED as it's forward voltage. 

If you are just using a single LED, you might want to measure the LED's forward voltage before putting everything together.  It would also allow you to fine tune your math.  Remember, the specs on the LED have between 3.2-3.8 volts.  That 0.6 volt range is large enough that it can really mess with your calculations.  So if you are just doing this once with a specific LED, just wire it up to a large(200'ish ohm) resistor and measure the voltage drop.  Then adjust your math as needed.

On an side note, if your worried about the voltage causing problems, I have a LED project I am working on right now that feeds +45.2 volts directly into a chain of serial connected LED's(15 total).  The voltage drop over each LED is small 2.8 or 3.7 depending on which LED type it is but it adds up to that 45 volt total.  So you won't have a problem here.

No idea what to recommend for a proto board maybe someone else can be more helpful.
Reply all
Reply to author
Forward
0 new messages