LED power input

When i connected an LED to an i/o pin and the ground, it worked, but when it was connected to the 5V output and the ground, it got burnt. Why would this have happened?
Isn't the output voltage of the i/o pins the same as the Vcc (which would have been 5V in this case)?

Thanks!

Usually, the voltage is about the same, perhaps a little less. But when you allow too much current to flow into or out from an I/o pin, the pin's voltage will be much less. This stopped your led from burning out quickly but it will still have damaged the led and reduced it's life. It will also have damaged the Arduino pin and reduced it's life too. You can put an end to this terrible cruelty to leds and pins by always using a series resistor.

Thanks :slight_smile:

The concept is simple...You are aware of the characteristics of a diode and led is a diode. Therefore as the voltage increases the current increases exponentially passing the limit and burning the led. Connecting a suitable resistor will allow a constant current to flow protecting your device and led.
say you require 5ma of current and your supply is 5v..then from ohms law you require 1k resistor.Hope this helps you in future
all the best