 # Resistors on shield...

What is the plus to having a resistor, or two on your shield?

The two resistors on your shield (http://www.ladyada.net/images/pshield/v5schematic.png) are to limit the current through the two LEDs. If you connect a 2V LED across a 5V line it will draw too much current and possibly fry. The resistor limits the current to 20 mA or less to protect the LED.

johnwasser: The two resistors on your shield (http://www.ladyada.net/images/pshield/v5schematic.png) are to limit the current through the two LEDs. If you connect a 2V LED across a 5V line it will draw too much current and possibly fry. The resistor limits the current to 20 mA or less to protect the LED.

Close...

The LED draws 20mA, the pin can supply up to 40mA. The LED has a forward voltage drop of 2v, the pin supplies 5V.

An LED is a semiconductor device and has no natural internal resistance of its own. With no internal resistance, I=V/R - no matter what the voltage, it's divided by 0, which is infinity (actually an "undetermined value" but in this case infinity is more understandable). Infinity amps is not good. The LED will draw all the current it can from the IO pin. If that is too much for the LED to cope with it will kill the LED. If it's too much for the chip to cope with it will kill the IO pin on the chip.

So, we need to introduce some resistance of our own so we're not dividing by zero.

The LED has a fixed voltage drop. Regardless of what we do it will remove 2V from the supply voltage due to the semiconductor junction at the heart of the LED. So, of the 5V from the pin there is 3V left. We now have two numbers we can punch in to ohm's law - the 20mA limit for the LED to function right, and the 3V excess voltage we need to remove.

Now, when current flows through a resistor it causes a proportional drop in voltage. So, using Ohm's Law, we can see that if V=I/R, R must equal V/I.

So, with V of 3, and I of 0.02 (20mA is 0.02A), then 3/0.02 is 150. A 150 ohm resistor will limit the current that flows from the IO pin to 20mA.

This only works because the voltages we are working with are fixed - the fixed 5V from the pin and the fixed 2V drop of the LED. So by introducing another "fixed" value (the resistor) we can "fix" the third value to what we want.