LED directly to output pin, or use resistor?

I have a 3mm IR LED. I can see

  1. hooking it up to a digital pin and setting digitalRead(led, HIGH), using only the Arduino pullup resistor to limit the current

  2. hooking the LED up to a digital pin, setting digitalRead(led, HIGH) AND then adding a series resistor as well

  3. Figuring out the forward voltage of the LED, then hooking it up to 5v with the appropriate resistor for say, 20ma (is this a good current?)

Which way is best?

1 is a bad idea. It provides little brightness andif you make a mistake and set the pin into output mode you burn out the LED.

  1. is what most people do

  2. is only necessary if you need to drive lots of LEDs (or high power LEDs). Arduino pins can drive up 10 LEDs at 20ma per led (or a little less so you are not running at the absolute maximum rating) The absolute maximum per pin is 40ma but the total should be under 200ma

using only the Arduino pullup resistor to limit the current

So in effect you are using a 30K pull up resistor, not much current down that.

See my new page all about this:- http://www.thebox.myzen.co.uk/Tutorial/LEDs.html

I thought the Atmega pullup resistors were 5k?

1 is a bad idea. It provides little brightness andif you make a mistake and set the pin into output mode you burn out the LED.

  1. is what most people do

if 1.. provides little brightness, how could 2 be any better?

Not knowing anything about the microcontroller, and since I just need the LED to remain on all the time, I think what I'll do is hook the LED in series with a 200ohm resistor to the +5v leg of the 7805 on my Boarduino. That's the way I figure it anyway....(5v-1.2v)/.020A = 200ohms

I thought the Atmega pullup resistors were 5k?

The data sheet says:-

RPU I/O Pin Pull-up Resistor 20 min 50 max k[ch937]