Saturday, January 5, 2013

Day 4: A Guide to Resistors

Well, I'm not feeling that well today so I figure I'll work on more theoretical stuff so that I can stay in bed. One of the things that has mystified me since I started these Arduino projects is the role of the resistor. I remember using these things when I was setting up circuits in physics class in high school, but I realized that I have no idea when or how to use what resistor. I thought I would do a little research to refresh my understanding of resistors and get a better understanding of how to use them with the Arduino.



The basic question I want to answer is the following: Why do I need a 330ohm resistor in my circuit when I attach an LED to an Arduino pin. I've been doing it since my very first circuit, but I have no idea why. Looking at various message boards proved useful. The first thing that I encountered as I looked for solutions to this question was the following equation:

V=IR where V is voltage, I is current (in amps), and R is resistance (in ohms).

This equation was sitting somewhere in the dim recesses of my memory, but I had no idea how to apply it to this situation. The next clue came when reading the specifications of an Arduino pin.

A digital Arduino pin, when set to output "High" outputs 5V. The pin is also rated at 40mA. This means that if I try to draw more than 40mA of current from any given pin on the Arduino, I might damage it. Plugging these two values into the equation above I get:

5V/0.04A=125ohm

This gives me the resistance of the resistor I need in an circuit (which plugs the pin directly into ground) with 5V to draw a current of 40mA. Playing with this relationship a bit, we can see that

5V/10ohm=0.5A of 5V/1000ohm=0.005A or 5mA

So then having a circuit with anything less than a 125ohm resistor would damage the Arduino pin. (There is likely some variance here due to the resistance in the wires themselves, so we could probably attach a resistor somewhat less than 125ohm.)

Now if we look at the LED that comes with the SIK, it says that there is a 1.8-2.2 voltage drop across the LED. Taking the median value of 2V, we can see that we now end up with:

(5V-2V)/0.04A=75ohm

So we have the value of the resistor necessary to keep from damaging the Arduino pin (75ohm). But now looking at the specification for the LED, it also says "Suggested Using Current 16-18mA." This means that, with a 75ohm resistor, we might not damage the Arduino pin, but we would damage the LED. To get the right amount of current to the LED we must recalculate:

(5V-2V)/0.017A=176.47ohm

In the kit, I have been using a 330ohm resistor which means:

(5V-2V)/330ohm=0.009 or 9mA

Judging from this, my LED is probably a little dimmer than it could be.

In writing this I found the first reply by lefty in this Arduino Forum to be extremely valuable. I also opened up a thread in the Arduino basic electronics forum where several people were extremely helpful. More on resistors later.


No comments:

Post a Comment