Connecting an LED

When connecting an LED to an output pin of the board, is it necessary to use a series resistor?
I notice that a lot of examples connect straight to the pin, (getting +5v when high) whilst others use a resistor in the circuit.

Always

I notice that a lot of examples connect straight to the pin

These are bad evil examples designed to destroy your arduino. See this link for why you always need a current limiting device. http://www.thebox.myzen.co.uk/Tutorial/LEDs.html

He is probably referring to this tutorial http://arduino.cc/en/Tutorial/BlinkingLED?action=diff which hasn't been edited in more than 5 years. It refers to an ancient Arduino which had a resistor between the output of the microprocessor and 'Pin 13'. Arduino tutorials are like the 'Roach Motel', articles go in but they never come out.

Don

floresta: He is probably referring to this tutorial http://arduino.cc/en/Tutorial/BlinkingLED?action=diff which hasn't been edited in more than 5 years. It refers to an ancient Arduino which had a resistor between the output of the microprocessor and 'Pin 13'. Arduino tutorials are like the 'Roach Motel', articles go in but they never come out.

Don

I found quite a few examples, but the one in particular was http://bit.ly/jjPi1M as I was trying to wire up a LCD. (There is no resistor on the LCD board, just 2 LED's in parallel to pins 15/16).

The back-light on an LCD display will sometimes have a series resistor on the board. But it is wrong to assume so.

Note that refers to a very old version of Arduino that DID HAVE a series resistor on the board.

I thought I said that in my post....

Don

I found quite a few examples, but the one in particular was http://bit.ly/jjPi1M as I was trying to wire up a LCD.

I contacted the Web page in question and I just got this reply back:-

We have been meaning to update the tutorial with this information. We have not had an issue with this because the ATMEGA IO pins are internally current limited below the LCD's backlight current spec. But I agree with you that it is poor design to depend on this, and misleading to beginners about how to properly wire up LEDs.

I will get that changed right away. Thanks for the feedback.

I also put him straight about the internal current limiting myth.

and he replied:-

I just checked the Atmel datasheet, and you are correct, I did not see any mention current limiting. I have read several tutorials, and forum posts over the years that mention the 40mA current limit, and I guess this idea just keeps propagating itself...

Thanks a lot for informing me about this. Now I can stop being part of the problem, and start being part of the solution.

So that's a result!!!