I read an article that said that shorting an IO pin to ground would destroy the pin. I've done this before when I connected a buzzer to an IO pin and to ground without resistors, the buzzer is only 14 ohms so the current would be quite high through the pins. Why is my Arduino still working, and how should I know when to use resistors or what rating to use?
The Arduino is tougher than it looks. ;-) Or maybe you were just lucky.
The exact point of failure of an IC is hard to predict, because of part to part variations, and because it can depend on many uncontrolled factors (duration of fault, temperature, voltages and currents on other pins, part history...). Then, the absolute maximum ratings are not the predicted point of failure. They are rather a lower bound:
- The part should not fail if you do not exceed the ratings
- it may fail anywhere beyond those limits.
Time is, however, also a factor. The manufacturer says that operating the part close to the limits for an extended period may shorten its lifespan.
You don't necessarily destroy the pin, but it won't do it any good. To work out the resistors use Ohm's Law. The continuous output of a pin should not exceed 20 mA, thus:
V = I * R R = V / I R = 5 / 0.020 R = 250
Thus 250 ohms, from the pin to ground, would allow a safe amount of current to flow.
As for the rating, that resistor would dissipate:
W = V * I W = 5 * 0.020 W = 0.1
Thus a resistor that could handle 100 mW would be required. More reasonably, a quarter watt resistor should be fine.