Use ARDUINOs internal current-limiting resistors for LEDs?

Hi,

i stumbled across the Arduino-page describing the digitalWrite-command and read that:

"If you do not set the pinMode() to OUTPUT, and connect an LED to a pin, when calling digitalWrite(HIGH), the LED may appear dim. Without explicitly setting pinMode(), digitalWrite() will have enabled the internal pull-up resistor, which acts like a large current-limiting resistor."

Which made me think that you could use a LED without the, otherwise necessary, current-limiting resistor. Would this be a correct assumption, or am i missing something vital here?

This would be useful if you are using the LEDs merely as indicators of some sort.

Any thoughts? :D

Best regards Adam

You can if you connect led between pin and ground. However, they will not be very bright when switched on.

The pull up has an equivalent value of about 30,000ohm, so the LED will be very dim. Not very useful. Leo..

Did you try it ?

Thank you all for your replies!

I'm aware of the limited light emission from the LED if driven through such large resistor, but i figured it would be useful to use for indication rather than illumination.

I need to do testruns on a whole bunch of sketches from students participating in a Arduino-course and would save myself some time if i could omit the external current-limiting resistors.

I have tried it, and could confirm that the LEDs are being lit as usual but are quite dim.

I guess my question is if this would somehow damage the Arduino-board or if there is other aspects i should consider before resorting to this solution.

Best regards Adam

How would one turn the LED off?

DrDiettrich: How would one turn the LED off?

That would be done exactly the way it is used to be.

You do still use digitalWrite(PINx, LOW/HIGH); to manipulate the PORT.

Best regards Adam

The LED will indeed light up, but it's really dim. Too dim for any practical purpose.

If you want a dim but still visible LED use a resistor of 2-5k or so. For a normally bright LED 330Ω is great for a 3.3V output, or 680Ω for a 5V output. Values may need to vary with the LED colour/type, especially blue and white LEDs need a lower value due to the higher V(F).

I need to do testruns on a whole bunch of sketches from students participating in a Arduino-course and would save myself some time if i could omit the external current-limiting resistors.

I'll tell ya' why this is a BAD IDEA... If one of the students accidently writes a high, you'll potentially fry the LED or the Arduino. Or maybe they do it intentionally to make the LED brighter.

If you want to make it easier, pre-solder some series resistors to the LEDs. When I solder resistors in-line with LEDs I usually heat-shrink over the resistor. If you do that, you might want to use clear heat-shrink so the students can see what's being done.

P.S. Plus... It's better & easier to teach the students about diodes & LEDs hand how to use LEDs the "normal way" than to confuse them with a screwy work-around.

Make yourself a little board with resistors, leds and flying leads - best solution .

adapet200: I need to do testruns on a whole bunch of sketches from students participating in a Arduino-course and would save myself some time if i could omit the external current-limiting resistors.

So the lesson will say LED current limiting resistors can be omitted ?

Good or bad plan ?

wvmarle: The LED will indeed light up, but it's really dim. Too dim for any practical purpose.

If you want a dim but still visible LED use a resistor of 2-5k or so. For a normally bright LED 330Ω is great for a 3.3V output, or 680Ω for a 5V output. Values may need to vary with the LED colour/type, especially blue and white LEDs need a lower value due to the higher V(F).

Yes, of course! This would be one way of doing it, but then again i could aswell use a more suitable resistor. The objective here isn't to essentially limmit the LEDs illumination, but rather to flash leds as indicators. (With current-limiting for the sake of the Arduino)

DVDdoug: I'll tell ya' why this is a BAD IDEA... If one of the students accidently writes a high, you'll potentially fry the LED or the Arduino. Or maybe they do it intentionally to make the LED brighter.

If you want to make it easier, pre-solder some series resistors to the LEDs. When I solder resistors in-line with LEDs I usually heat-shrink over the resistor. If you do that, you might want to use clear heat-shrink so the students can see what's being done.

P.S. Plus... It's better & easier to teach the students about diodes & LEDs hand how to use LEDs the "normal way" than to confuse them with a screwy work-around.

I never said i was going to teach the students about this! This would be done at home, by myself, at my desk, with my Arduino, testing the programs that students send me. (However, due to laziness the resistors are often excluded during the lab-hours at school. I actually thought fo a while that the Arduino somehow limited the current internally, and hence told students that the LEDs would be unecessary. (This is what i was told when i took this course myself 2-3 years ago.) However, after som research i corrected myself and now the students know how and why to pick a current-limiting resistor. No imidiate harm done to neither LEDs nor Arduinos.)

The pins can handle up to about 40mA (absolute maximum rating), limited by the silicon inside. That's why it won't kill the LED right away, but it will kill the Arduino pin or the LED after a while.

It's just a bad idea overall. To save your pins (and Leads) limit the current to no more than 20 mA. For most LEDs 5-10 mA is more than enough.

adapet200: This would be useful if you are using the LEDs merely as indicators of some sort.

You can use ULN2803a which is relay driver. I use this in my project for home automation and led add between Arduino pin to ground with 330 ohm resistor and same Arduino pin connect to input of ULN 2803a. With this setup you can also drive 500 mA from Arduino pin. Detail is in below link

https://www.sparkfun.com/datasheets/IC/uln2803a.pdf

That's total and utter overkill for driving a single LED from a pin. It's even overkill to driver a basic relay (a simple BC547 + base resistor does that just fine).

Go buy LEDs that have [u]internal[/u] 5V current limiting resistors ! End of topic.

https://www.ebay.com.au/itm/Pre-Wired-3mm-LEDs-With-Resistors-Various-Colours-5v-6v-9v-12v-Pack-of-5/122552395488?hash=item1c88b126e0:m:maot8H77wGg929xOnytx3jA

https://www.ebay.com.au/itm/2-pcs-DIALIGHT-P-N-555-4004-2mm-dia-QUAD-RED-LEDs-With-Internal-5V-Resistor/270338118875?epid=1018179937&hash=item3ef16854db:g:pgMAAOSwsFpZ~70P

https://www.ebay.com.au/itm/50pcs-Lumex-SSF-LXH141ID-5V-Red-5mm-LED-with-PCB-holder-5V-no-resistor-required/151327280615?epid=1928636913&hash=item233bcf0de7:g:nMoAAOSwoydWottQ

etc...

Thank you all for your comments and suggestions!

Just to clarify a bit:

I DO know that sourcing more than (or close to 40mA for a longer period of time) is bad for the Arduino (or rather the Atmega-chip).

I know that using such a large resistor (the internal pull_upp resistor) would drastically limit the light emission from the LED - but who uses those LEDs, connected to the Arduino GPIO, for illumination-purposes anyway? ;)

The whole point of doing this is to be able to light LEDs without the external resistor. (For debuging etc.)

Thank you Ghulamfarid, i will look into that, even though i'm not going to use that in this situation i like to learn about different parts. (And yes, for tjese relatively small currents, i would rather use a BJT for example)

Regards Adam

Thanks lastchancename, i have heard about theese, but i'm not very impressed.

This solution does not suffice as an finalement to the topic. I would like to know if this procedure is in any way harmful for the microcontroller, being that it "expects" an INPUT if pinMode() is not called in the setup-function.

Regards Adam

Remind me to drive a LED from the positive 5v pin to the positive 3.3v pin. 1.7 volts potential is perfect for a lot of LEDs..

Slumpert: Remind me to drive a LED from the positive 5v pin to the positive 3.3v pin. 1.7 volts potential is perfect for a lot of LEDs..

? Can't do that. The 3.3volt supply can only source, not sink. Because there normally is no load on the 3.3volt rail, to use that current.

adapet200: I would like to know if this procedure is in any way harmful for the microcontroller, being that it "expects" an INPUT if pinMode() is not called in the setup-function.

I don't see a problem doing that. Internal pull up is mainly used with a switch between pin and ground. In which case it is normal to short the pin to ground.

And I think pinMode is actually used/called internally. The new/preferred way to enable pull up is not

digitalWrite(pin, HIGH); but pinMode(pin, INPUT_PULLUP);

Never switched pull up off with digitalWrite(pin, LOW); but if it works, it works. Leo..