Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

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.

share|improve this question
1  
The TL;DR answer is yes, but do use a series pull-up or pull-down current limiting resistor –  Andrew Dec 20 '12 at 11:47
add comment

2 Answers

up vote 5 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
    
Just in case: for 2.25V and 20mA LED, that works out at about 50 ohms, is that right? –  Benjol Dec 18 '12 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 Dec 18 '12 at 22:37
    
OK, thanks for that. So I need to be looking for some more reasonable LEDs. (What's a buffer?) –  Benjol Dec 19 '12 at 6:19
2  
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 Dec 20 '12 at 3:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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