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.

While looking for a basic task to get familiar with the Raspberry Pi and it's GPIO pins, I decided that driving an LED sounded simple enough.

While investigating how to go about this task I've noticed that most instructions indicate to place a resistor between the GPIO pin and the LED. The size of the resistor varies by instructions, but typically in the range of 260 ohms to 1K ohm.

However, none of the instructions indicate the reason for this nor do they indicate why they've chosen a (seemingly) arbitrary resistor size.

Why is a resistor even needed, and how would you know what ohms it should be?

share|improve this question

2 Answers 2

up vote 19 down vote accepted

The reason is common to all LED applications, not just Raspberry Pi (or the GPIO pins).

An LED can only pass so much current before it will destroy itself (very brightly!). The maximum current varies by the LED's size and colour, but for a medium-sized red LED can usually be assumed to be 20mA (check this value though, if you have the spec sheet for the LED handy - and tiny LEDs can only handle a tiny fraction of this).

A standard red LED usually has a voltage drop of around 1.7v, and so the value of the resistor can be chosen to pass 20mA at (voltage - 1.7). Assuming an input of 5v, this means a resistor that will pass 20mA at 3.3v, which (using Ohm's Law) gives us an absolute minimum resistance of 165 ohms.

The worst that can happen by using a larger resistor, is that the LED will be dimmer than its maximum brightness, and so in order to accommodate smaller LEDs that can only pass 10mA, it's not uncommon to use 330 ohms and above.

I'd put a 470-ohm resistor in for a 5v supply for a medium-sized red LED, and if the LED is way too dim then reduce it slightly.

If using a miniature red LED, then 1K ohms does not sound outrageous, and for more exotic colours (in particular blue, pink and white), you will want to calculate the value yourself.

share|improve this answer
Thank you, that helps a lot. –  Jason Whitehorn Jan 7 '13 at 14:48

This is not a question for Raspberry PI section, rather you should ask it to electronics section.

First of all, LED is a semiconductor diode. An current - voltage relationship inn diode (in general):

I=I(s)*[exp(eV/nkT)-1] (though this relation is not exactly real)\

And the most notable thing is that a small change in voltage produces larger change in current. And this is driving reason behind using a resistor with led in series.

Another thing is that generally operating point of an LED is < 5Volts (roughly 3.3V). That is why we use a resistor of proper value in series with LED.

Go through http://www.evilmadscientist.com/2012/resistors-for-leds/ And you will get the idea of how to pick proper resistor for a specific LED

share|improve this answer

Your Answer


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.