I connected a green LED to pin 13 and digital GND
on Arduino Uno R3. pinMode
was set to OUTPUT
and digitalwrite
was set toHIGH
. The LED glowed normally.
However connecting same LED to the 5V and GND
burnt it out. How?
Did not pin 13 on HIGH
also have voltage of +5V ?
-
\$\begingroup\$ Have you looked at the schematic yet? \$\endgroup\$Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2014年08月18日 18:12:43 +00:00Commented Aug 18, 2014 at 18:12
3 Answers 3
The microcontroller at the heart of the Arduino can handle about 40 mA of current per pin. Connecting the LED (apparently without a current-limiting resistor) directly to 5V and ground will cause it to burn out, as it pulls more than its rated maximum current.
Pin 13 will also be 5V, but the current is being limited (not in a good way) by the microcontroller. The LED will try to pull more, but the microcontroller can't source it, so the LED doesn't burn out (as quickly). However, the microcontroller is not designed to be a current limiter, so connecting an LED directly to an output pin can cause damage over time. How much current the LED tries to pull, depends on the LED.
Most standard LEDs operate with about 20 mA, and can handle shorter durations of higher current.
You need to use a current-limiting resistor with your LED, regardless of whether you use a digital pin or connect it directly to Vcc.
The digital pins of the Arduino can only source 40mA, the 5V rail can source much more than that depending on supply.
The LED blew up because you did not have a current limiting resistor. See here. When you attached 5V across the LED it likely tried to pull amps of current and instantly smoked. See this relationship. enter image description here
See how if you apply 5V, the current it would try to pull is exponentially higher than 40mA. The LED you used was likely rated for 20mA continuous. Poof
Additionally, if you put a voltmeter across the LED when connected to the digital output, you would not read 5V, likely around 2.2V if you used an LED with a similar curve to the generic one I posted. This is due to the arduino limiting the current to 40mA.
-
\$\begingroup\$ @immibis: Your eyes are deceiving you, it's an exponential relationship \$\endgroup\$Ben Voigt– Ben Voigt2014年08月19日 03:31:34 +00:00Commented Aug 19, 2014 at 3:31
-
\$\begingroup\$ It's possible the graphic was drawn by hand, or was pieced together on computer using a curve and a straight line intersecting at (1.8, 5), or similar. Sometimes it's quite obvious a graphic is not a computer generated plot of an exponential curve (or sinusoid etc) but rather whatever was expedient to create in a graphic design tool. The V-I relationship of the actual component should be exponential. \$\endgroup\$Matt B.– Matt B.2014年08月19日 05:01:23 +00:00Commented Aug 19, 2014 at 5:01
-
\$\begingroup\$ I agree, the graph looks linear but should be exponential according to Shockley's equation. I just picked the first google hit. \$\endgroup\$ACD– ACD2014年08月19日 12:25:03 +00:00Commented Aug 19, 2014 at 12:25
The Arduino output pins do not have hard, low resistance, switches to connect to +5V or ground - they use transistors which have a significant resistance which will limit the current the pin can deliver.
When you connect the LED across the power supply directly, the power supply will deliver as much current as it can in an attempt to maintain 5 volts - this will destroy an LED.