# Very basic questions on resistor and gnd

Im a total beginner. I bought an arduino starter kit and this is the first sample program - it makes an LED blink. The accompanying text gives no theory about what is happening in the sample programs so I have a couple of questions.

1. What is the function of the resistor here?
2. Why is it a 560 ohm resistor (as opposed to 2 ohms or 20000 ohms)?
3. The circuit starts from arduino pin 13 that I understand puts out a voltage of 5 Volts. But the circuit then ends at gnd. I thought circuits were supposed to loop around so that the currently will keep flowing non-stop? What is the reason for the circuit terminating at gnd?

Here is the circuit -

• You were probably limited by new user restrictions, in the future, when you have the rep, please use the image tool to place the images inline. – Kortuk Jan 7 '12 at 15:33

In brief:

1. The resistor in this circuit is a "Current Limiting Resistor"
2. The resistance is dependent on the forward voltage drop and current requirements of the LED.
3. Ground forms part of the circuit. The microcontroller is also connected to ground. It is a reference point that all other voltages in the circuit are measured against.

In more detail:

The LED requires a certain amount of current to light up. It also has a certain voltage that it operates. These are never the same as the 5v Arduino puts out through its IO pins. So, if the LED has a forward voltage of 2.2V and a maximum current rating of 25mA, and the Arduino puts out 5V, then we need to lose some of that voltage to get it down to 2.2V. The resistor does this for us.

We calculate the value of the resistor by using Ohm's Law, which states that:

$R=\frac{V}{I}$

Or, the resistance is the voltage divided by the current.

So, for our LED of 2.2V we will need to lose 2.8V using the resistor. The LED can draw 25mA (max without burning up), as noted above.

So, we can put those values into our Ohm's Law formula:

$R=\frac{2.8}{0.025}$

Which gives us the answer 112Ω

For the LED I picked at random above, you'd use a 112Ω resistor to stop it from going pop. As they don't make 112Ω resistors commonly (you can get any value made, but they cost shed loads), the next value up is chosen - typically 120Ω.

Without knowing the exact specs of your LED it's impossible to know exactly what resistor should be used, but a higher value resistor is safer than a lower value one (it just may not light up as bright) and around the 500Ω area is a reasonable value to cover most LEDs.

As for the ground connection - that is just another wire - the "return" connection that keeps the current in a loop. Just because it's called "ground" it doesn't make it special - it's just a reference point. The 5V in the circuit is actually "5V With Reference to Ground". All parts of the circuit marked with the ground symbol are all connected together - it just saves drawing in the wires.

• I just approved an edit on your answer that seemed valid, please ensure that I have not added technical inaccuracy to your question. – Kortuk Jan 9 '12 at 2:38

A simple light bulb can work straight on say 3V, 5V, 12V (depends on what one you get). A LED is different, it requires a certain amount of current to pass through before it lights up. Because a LED is a kinda of diode (the symbolic shows that), the voltage remains almost constant when it's conducting. It will rise a bit, but that's almost negligible.

A typical LED requires a minimum of 1 or 2mA to light up. Most have a maximum of about 20mA. The voltage depends on the colour and sometimes type of LED you have. Let's say you have a simple red LED. Typically it would say '2V drop at 20mA'. That means that if you run 20mA through it, there will be a 2V voltage drop (NOT the other way round - this may be kinda hard to understand at first). But, we have a 5V supply right? So if we put 5V on it, the LED will conduct far more than 20mA and will blow up. What we want is to make a circuit that the resistor takes 3V up, and 20mA will flow through both the resistor and LED (because they are in series).

We can do that with Ohm's law. It describes the relation between current and voltage of a resistor: R=U/I In this case we want U 3V (the voltage across the resistor) and I of 20mA. So we fill it in: R=3V/20mA = 3V / 0.02A = 150 ohms.

Now, because the LED is running of an Arduino, the microcontroller may not be able to deliver 20mA. Furthermore, I don't know the exact specifications of the LED, which may be different. So I assume they have calculated their 560 ohms on good basis.

Why it's obviously not 20k or 2 ohms.. well. If you put the whole 5V on a 20k resistor, you only get 0.25mA of current. Assuming the LED will take a little bit, there nearly won't be any light at all. If you take 2 ohms you're going to blow the LED up. There will be so much current flowing that the LED is toast.

As for the arduino; A arduino contains a microcontroller chip. These are intelligent devices which can change the output of a pin. It can make a pin high (make it 5V), or low (make it 0V). We can program that by software. If you make the pin high, it will just put 5V on your LED and resistor. Current will flow, LED will light up etc. If you make the low, it will put 0V on the LED and resistor. That will not do a whole lot, and the LED will be off.

Circuits always require a loop indeed, but the microcontroller has hardware inside it to fix that. Think of it as switches inside that will connect the either the 5V supply to pin 13, or GND (if its state is low). The LED and resistor is connected to ground so it completes that circuit. We could also have done it the other way around, but then the LED will be ON if you make the pin low (0V) and off if you make the pin high (5V).

• if 20mA gives exactly 2V drop then 2V exactly will give 20mA. It just happens that 2.04V will give a lot more current then an extra 2%(20.4mA). Instead it is a non-linear relationship. This means a voltage regulated supply regulated to 1% will not work even close to as well as a current regulated supply regulating to 1%. With a current regulated supply you can power without a resistor, but of course we use voltage suppliers because they are much easier to build. Not criticizing you, just something I thought could use being expanded on. – Kortuk Jan 7 '12 at 16:18

3. I thought circuits were supposed to loop around so that the current will keep flowing non-stop? What is the reason for the circuit terminating at gnd?

That's right. There has to be a complete loop to allow electric charges to flow around the loop, and to allow electric power to flow from the battery to the LED.

In this case, the electric charges flow (very slowly) in a closed loop through the resistor, through the LED, through a switch inside the Arduino connected to the +5V pin, through the voltage regulator, through the battery, and back to the resistor.

The electric power flows (very quickly) from the battery to the LED along a path (the Poynting-flow) that's so complicated few people ever bother trying to draw it.

In fact, we usually don't even bother drawing the entire loop for the path the electric charges flow. We often have dozens of devices that each have at least one pin that must physically be wired to the negative end of the battery. But rather than drawing dozens of lines from the battery to dozens of devices all over the schematic, we symbolize that connection with the little triangular "ground symbol".

Sometimes we make symbols for other points that lots of wires and lots of components are connected to. So my schematic may have an group of components with "+5 V" up top and "GND" below that appears isolated from anything else on the schematic.

But that group of components isn't really physically isolated from everything else. It's part of a complete loop. Much as when I mention rain falls on my head and then drips from my clothes onto the ground, I'm not saying the water came out of nowhere and then mysteriously vanished when it hit the ground -- I'm leaving out the details of the watershed and river formation and the water cycle because that completion of the loop is common knowledge.

(I'm assuming you're using a 12 V battery to power the Arduino and (indirectly) the blinking LED. There are many other power sources that will blink the LED just as well, but they are more complicated to explain).