4

I was wondering if it is possible to connect an LED directly to one of the GPIO pins of the Pi? The reason I ask is that, I have read from many sources that if I am not using some sort of break out board, then I run the risk of breaking or frying the pi entirely. And do the GPIO pins provide enough current to power a single LED assuming that it is okay and safe to connect an LED directly to one of the GPIO pins directly?

Thank you.

1
  • 1
    The TL;DR answer is yes, but do use a series pull-up or pull-down current limiting resistor
    – Andrew
    Commented Dec 20, 2012 at 11:47

3 Answers 3

8

You can connect an LED directly to the GPIO pins (it will provide enough current).

However, you probably shouldn't do this for a couple of reasons, You can fry the Pi as you state, and without a current limiting resistor you will signifcantly reduce the life of the LED. This does not mean you need to buy a breakout board to run a single LED. You can use a simple protection circuit to protect your PI. This article has a good discussion on protecting your Pi's GPIO from damage.

If you plan to experiment beyond a simple LED a breakout board that includes GPIO Protection can be a good investment and time saver.

16

You can connect directly to the IO pins. The GPIO pins on the RasPi processor (BCM2835) supply 3.3v @8ma of drive by default but are programmable as far as pull-up, current, slew rate, etc. see http://www.scribd.com/doc/101830961/GPIO-Pads-Control2 for a summary.

Having said that, unless you're adept at programming those pin parameters, you probably want to limit current with a resistor. Assuming your LED needs 1.5 volts @ 5ma, 3.3v - 1.5v = 1.8v drop. R = E/I so R = 1.8/.005 = 360 ohms should be safe.

Solder this resistor to one leg of the LED. One side of the LED/resistor goes to the GPIO pin, the other side goes to ground.

5
  • Just in case: for 2.25V and 20mA LED, that works out at about 50 ohms, is that right?
    – Benjol
    Commented Dec 18, 2012 at 12:46
  • The pin can only source or sink 16ma max, 8ma by default.. You will need a buffer if you truly want to drive the LED with 20ma. If it could supply the current then yes... You only need to drop 1.05 volt, so the dropping resistor should be 52 ohms or so.
    – BobT
    Commented Dec 18, 2012 at 22:37
  • 1
    OK, thanks for that. So I need to be looking for some more reasonable LEDs. (What's a buffer?)
    – Benjol
    Commented Dec 19, 2012 at 6:19
  • 3
    8ma will give you a pretty bright light from a small LED. As far as buffers go, in this case a buffer is a circuit that (for instance) takes a small current drive as an input and sources (or sinks) a much larger current on its output. They are used for driving relatively high current peripherals from low current outputs. An LED is one example, a relay might be another. See evilmadscientist.com/2012/basics-open-collector-outputs for an example of IC buffers. For a discussion of driving LED's with a RasPi see elinux.org/RPi_Tutorial_EGHS:LED_output
    – BobT
    Commented Dec 20, 2012 at 3:26
  • From the linked document: "The current value specifies the maximum current under which the pad will still meet the specification. IT IS NOT: The current the pad will deliver. IT IS NOT: a current limit so the pad will not blow up. The pad output is a voltage source." This means that you can't limit the current with programming, and you DO NEED a resistor to limit the current to your LED.
    – lvella
    Commented Apr 27, 2016 at 5:43
0

There are LEDs with an integrated resistor which can directly be used with 5V, or possibly 3.3V

http://www.mouser.lu/new/kingbright/kingbright-resistor-LEDs/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.