Are Resistors Mandatory?

In my LED build they are connected to digital pins, illuminated with analogWrite(3,x) where x is a loop-generated PWM value between 0 and 150. When I meter it on my bench Agilent the mA peak never exceeds 16mA. So, is a resistor required in this case?

FWIW - The same LED when metered on analogWrite(3,255) pulls 57mA. That's bad news I think; however, except for botched code it won't happen in the actual routine.

Thanks.

I know the Agilent's I use puke on their shoes if you read them faster than once a second, so ... what is your real peak current?

in a nutshell its sampling at X frequency and averaging them, in reality you are pulsing around 57ma really fast, which may be fine for your LED but is beyond spec for the AVR

and yes I would use a current limiting device regardless cause the forward voltage of the led will change with temperature and time

Yea, I see your point. I want to limit the draw to 20mA MAX, right?

pulsing a led usually can be quite higher than a constant on in terms of current, 40ma is the absolute max for a single pin of the avr on the arduino (250ma total for the whole thing)

For driving leds directly from arduino yes... always

dotJason:
So, is a resistor required in this case?

YES!

cjdelphi:
For driving leds directly from arduino yes... always

except when pin was placed in INPUT_PULLUP mode.

One solution would be to connect the pin to a transistor via a 1k resistor then you need not worry about current draw at all... using pwm to the base pin will allow analogWrite to work...

cjdelphi:
One solution would be to connect the pin to a transistor via a 1k resistor then you need not worry about current draw at all... using pwm to the base pin will allow analogWrite to work...

Maybe you could sketch that out?

cjdelphi:
One solution would be to connect the pin to a transistor via a 1k resistor then you need not worry about current draw at all... using pwm to the base pin will allow analogWrite to work...

you are just using more components to shift the problem somewhere else

You need to limit the current somehow - either by a resistor or by a constant current driver of some sort.

So resistors are not mandatory if you have a constant current driver chip / circuit.

Never used a transistor before? I'll gladly teach you....]

cjdelphi:
Never used a transistor before? I'll gladly teach you....]

Heaven forfend.

Sorry never like Baited questions... esp when the person skips facts