-1
\$\begingroup\$

This question already has an answer here:

I know next to nothing about electric engineering, so I got the Arduino Uno R3 and a bunch of LEDs to play around with and hopefully learn something. I have no idea about the proper terminology or anything here, so bear with me ...

When I connect an LED to a normal pin, it works fine. When I connect it to 5V or 3.3V with a 220 ohm, it works fine. Without the resistor, the LED gets cooked. My question is, why does it work with the digitals without resistance and not the 3.3V or 5V? Are they hooked up to onboard resistors? What is their output?

And finally, where can I learn more about my shiny new microcontroller without diagrams that I can't make head or tail of?

Edit: I think this is different from the related question I noted in my comment, but tell me if I should remove it anyway.

\$\endgroup\$

marked as duplicate by JYelton, Nick Alexeev, Dave Tweed, Matt Young, placeholder Sep 29 '13 at 23:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ @user29797 do you have the pin configured as an output, and have performed a digitalwrite(high) to it? \$\endgroup\$ – Andyz Smith Sep 29 '13 at 23:47
-1
\$\begingroup\$

as noted by OP's reference to this question probably because the Arduino itself cannot supply enough current through it's output pins to damage the LED. But you very well might be damaging your Arduino.

\$\endgroup\$
  • \$\begingroup\$ As noted in that question, the pin can (against recommendations) supply 120mA, 5 times the typical current in an led. Definitely can damage the led. \$\endgroup\$ – Passerby Sep 29 '13 at 22:54
  • \$\begingroup\$ @Passerby why doesn't it,according to several observations by question-askers? \$\endgroup\$ – Andyz Smith Sep 29 '13 at 23:42
0
\$\begingroup\$

When lit, LEDs try to maintain a near-constant voltage across themselves. The voltage varies with LED colour and composition - Red is about 1.8 volts, yellow 2.0 volts, and green 2.2 volts. Blue and white LEDs are 3 volts or so.

The digital outputs of your Arduino cannot supply unlimited current - I think (without consulting the datasheet) their rated maximum is about 20 mA. and there will be a volt or so across the output transistor when delivering that current, so the output characteristics of the Arduino will limit the voltage across the LED. (the voltage and current may still be excessive, and will stress both the LED and the Arduino.)

When you connect the LED directly across the power supply, the power supply can easily supply sufficent current to destroy the LED.

You must always use a resistor in series with an LED to limit the current to a safe value, even when it is driven by a microcontroller.

Typical LEDs have a maximum rated current of about 20 mA, but will work fine (but dimmer) at much lower currents - I usually design for less than 10 mA. To calculate the resistor value, use Ohm's Law, with the voltage = Supply voltage minus LED voltage.

\$\endgroup\$
  • \$\begingroup\$ Excellent answer, thank you. Also, I found this page about LEDs which seems to be very thorough and without too many diagrams (and it seems to confirm the 20 mA rating). Recommended for other beginners. Please tell me if you have any other suggestions for good resources. \$\endgroup\$ – user29797 Sep 29 '13 at 22:05
0
\$\begingroup\$

This is because of Voltage Droop. As you pull more current, the voltage on the ATMega's pin drops. Since LEDs have a correlation between voltage and current, this causes a sort of self-balancing act. (The First Picture is an LED v vs i graph, the second is the Pin driver v vs i graph from the ATMega328 datasheet)

enter image description here enter image description here

The led and the pin driver eventually come to an equilibrium. As the source voltages drops, the led wants to pull less current. The problem is that this might be at a current that can damage the pin driver, AND damage the led. It might not be immediate, but it can drastically shorten the life of the Driver, and of the LED, and harm the accuracy of the driver as well.

Individual Arduino/ATMEGA Pins should only source 40mA, and that's with a 0.6V droop, The Port should only source 100mA, and the entire Microcontroller should only source up to 200mA. These are the limits of safe/recommended/tested use as stated by the manufacturer. Any more than that stresses the microcontroller, might be okay, might not, but it's a gamble.

There is NO current limitation in the pin driver. If you short a logic high pin to ground, you just drew a few Amps and killed the driver. If you want to pull 100mA from a 40mA recommended max pin, you can! It is up to you, the designer, to restrict current draw. The 40mA is a recommendation, like a speed limit. You can drive faster than the limit, you shouldn't for obvious reasons.

Leds can be driven above 20mA. That is the Typical rating for x amount of hours. You can give it more, it will be brighter, but will die sooner. ANd it's really because of heat concerns. The more current, the hotter the led junction gets, the more current it wants to let through and eventually it falls into thermal runaway.

In short, you can directly connect the led, and through a unintentional combination of factors, it will not blow up (immediately). If you hook up a red led (1.8~2.0v) directly to a 5v pin without a resistor, it will probably die, but a blue or green or white one might not.

Last thing, you can use the internal pullups in the ATMega to safely light an LED. The internal pull up of 20k will allow enough current to light an led, dimly.

pinMode(pin, INPUT); // set pin to input

digitalWrite(pin, HIGH); // turn on pullup resistors

\$\endgroup\$
  • \$\begingroup\$ i cannot understand from your explanation, why, when connected to a 'non-current-limited' source such as the digital IO pins, the LED failure behavior is different than connecting it to the power supply directly. \$\endgroup\$ – Andyz Smith Sep 29 '13 at 23:49
  • \$\begingroup\$ i guess really i'm confused why you assert that there is 'no current limitation in the pin driver', but make use of documenation labeled 'pin driver strength'. can you succinctly explain to one lowly as me, what is pin driver strength? \$\endgroup\$ – Andyz Smith Sep 29 '13 at 23:54
  • \$\begingroup\$ @AndyzSmith Essentially, it means that the Pin cannot drive its output to Voltage X at Current Y. As Current sourced Increases, Voltage Decreases. If you want to make sure an output pin is at least 4.7v, you need the current at least under 10mA. At 40mA, the voltage of the pin that should be logic high/vcc/5v is actually 4v. (Same applies to output low and sinking current. As current increases, the voltage rises from 0v to 0.5v or more) \$\endgroup\$ – Passerby Sep 30 '13 at 0:10
  • \$\begingroup\$ so, the current on the output pins IS limited. by the fact of this curve, will eventually cause any given load to stop pulling current as the voltage decreases to zero. These output pins are current limited in a way that the power supply pins are not. \$\endgroup\$ – Andyz Smith Sep 30 '13 at 0:18
  • \$\begingroup\$ @AndyzSmith No, these limit current the same way power supply pins limit current. Remember bulky linear wallwarts? A linear power supply listed as 12v 500mA, would at no/light load, have 18v, and at 1A would have 3v. Linear Regulators have Dropout Voltages that Increase as Current increases. A LM7805 will not produce its max current at a vin-vout of less than 2v. They all act like low value resistors. The output pins are exactly like most linear power supplies, except with poor voltage regulation and weak current source capacity. \$\endgroup\$ – Passerby Sep 30 '13 at 0:30