An indicator LED datasheet says it has 20 mA Continuous Forward Current.
A micro-controller datasheet says its pins are 5 mA.
The LED will be powered by the micro-controller pin.
Would connecting the LED to the micro-controller pin harm the pin?
Should the LED have a current limiting resistor?
wolfv:
Is it OK to connect a 20 mA LED to a 5 mA pin?
An indicator LED datasheet says it has 20 mA Continuous Forward Current.
A micro-controller datasheet says its pins are 5 mA.
The LED will be powered by the micro-controller pin.
Would connecting the LED to the micro-controller pin harm the pin?
Should the LED have a current limiting resistor?
Thank you.
Which microcontroller? Most AVR chips can supply up to an absolute max of 40mA, and 20mA is a safe level.
If the micro can really only supply 5mA safely, you can't drive the LED with it. You'd need to use a transistor, switched by the micro.
And LEDs always need a current-limiting resistor. That's the law.
wolfv:
Teensy LC has 4 - 20mA pins and 19 - 5mA pins.
Right, an ARM-Cortex processor. Is 20mA the absolute maximum current, or the safe maximum. If it's the safe maximum, try to do as Graynomad suggests, otherwise use an NPN small-signal transistor with it's base switched by the Teensy. A BC548 or similar would do nicely.
A 2K7 to 4K7 resistor could be used between the output pin and the base of the transistor, then if also powering the LED from 3.3V, the series resistance is calculated: R = ((3.3V-Vce(sat)) - Vf)/0.02 , where Vf is the LED's forward voltage and Vce(sat) is the voltage between the transistor's collector and emitter when it's turned on. (For such a small load, Vce(sat) can really be ignored.)
So if the LED Vf is 2.0V, the series resistance would be: R = (3.3-2.0)/0.02 = 65Ω. A 68Ω resistor would do the trick.
wolfv:
Can a current limiting resistor limit the current to 5mA?
And note, you should never run a led without current limiting, in it's simplest form a resistor. Not even on the 20mA pins. And modern leds are very bright at 20mA so as an indicator 2mA is probably more then enough.