I have an Arduino uno. I planning to build a circuit with a parrellel circuit with 2 leds in series in each branch.
We'd need to see a schematic...
If you want 15mA, base your calculations on 15mA.
[u]Ohm's Law[/u] says Current = Voltage/Resistance. That means the current is determined by the load resistance (and the voltage which is either 5V or zero).
But, we can't know the resistance of the LED in advance because the resistance of an LED (like all diodes) changes with voltage. But, we know from [u]Kirchhoff's Laws[/u] that in series circuits the voltage is divided among the components so with 2.2V across the LED we have 2.8V across the resistor. And we know that in in series circuits the same current flows through all components so the current through the LED is the same as the current through the resistor.
So we can calculate the required resistance from Ohm's Law: R = 2.8V/.015A = 187 Ohms. (You can use a "close" standard resistor value.)
If you want to run two LEDs in parallel each LED should have it's own resistor because part variations can cause the current to divide unevenly between the two LEDs and they might have different brightness. (And in that case the current would split with approximately 7.5mA through each LED).
With each led having a separate resistor and both LEDs operating at 15mA the total current supplied from the Arduino is 30mA. Note that the "absolute maximum" allowable current from a single output pin is 40mA.
If it's just a small indicator LED, chuck a 1K resistor on it and don't worry too much about it. It just needs to be bright enough to see, the exact value of the current is not that critical.
Just make sure are you connecting two LED in series? Or you have two parallel branches with one LED in each? Also are you connecting it to one pin or separate pins?
In general, with most colurs LEDs you will get away using 220 Ohm resistor in series when connected to 5V higher resistance will make them dimmer. If you know current, they require, and junction voltage just use Kirchoff’s Law. DVDdoug explained it very well.
Grumpy_Mike:
I think not, that is used for determin how multiple current paths behave, nothing to do with this discussion.
Kirchhoff's laws are very relevant here. Both of them:
Kirchhoff's Current Law (KCL) tells you that the current through the LED is the same as the current through the resistor. (The sum of currents in a node should be zero, this is just conservation of charge.)
Kirchhoff's Voltage Law (KVL) tells you that the voltage across the resistor is the voltage of the source minus the voltage across the LED. (All voltages in a loop sum to zero, this is just a special case of Faraday's Law of Induction, where the magnetic flux is constant.)
That is what I hate about formal electronics, going round the houses to state something obvious. I remember I taught the subject in a University.
Description of Kirchhoff’s laws used to leave the students cold. But explain it in plane English and they got it. Then if you do need a formal definition then you can turn to it.
Do you honestly think that pointing a beginner such as the OP to Kirchhoff ‘s laws is any help at all?
Application of Kirchhoff's laws (or anything else, really) in simple cases like this one certainly helps understanding it, so you can apply it in more complicated cases as well.
Grumpy_Mike:
Do you honestly think that pointing a beginner such as the OP to Kirchhoff ‘s laws is any help at all?
Yes I do.
Do I know that for sure? Of course not, but if it doesn't, OP can just ignore it. Otherwise, he has learned something new, or at least now knows that something like these laws exists if he ever needs them.
deckard33:
Obviously I need a resistor. Do I use 15mA or 20mA to calculate this?
Do I need to alter the Arduino code to get the Arduino to discharge 15mA or will the LED work of the 20mA.
15mA is likely to be very bright. You can't look at it directly under typical indoors lighting. Pick a lower current like 5mA or 2mA.
Change the resistor later if you feel you need to change the brightness.
The Arduino is a voltage source. It cannot control the current. That is why it can be damaged by something silly like shorting an output direct to ground.
The resistor controls the current. Use the LED voltage to work out the voltage the resistor sees and then apply Ohm's law: R=V/I