# LED Bar Graph Resistor

Hi,

I am very new to electronics and using the arduino to learn. I am going through an learning about the different components one by and I am attempting play with an LED bar graph based on the following instructions: http://www.arduino.cc/en/Tutorial/BarGraph.

My quesiton is this: why are the placement of the resistors after the LED's and not before? From what I understood it was desirable to put a 220ohm resistor prior to LED's to prevent damage. This instruction set shows the resistor between the LED and ground.

Whether it's pin-to-resistor-to-LED-to-Gnd or pin-to-LED-to-resistor-to-Gnd makes no difference; it's a series circuit.

Thanks, after reading up a bit this makes a bit more sense - the order doesn't matter because the current will be the same for each component in the series... is this right? (for example, in the first tutorial in which an ED simply blinks, the resistor could have been before or after the LED?)

Follow-on question: when calculating the amount of current going through components connected to a pin, do you treat each digital pin as series connected in parallel to one another i.e each receiving 5v, which then in the mentioned schema means each pin has ~22mA of current flowing through it.

sorry, i know this is the most base-level questions, but i am trying to learn by tutorials and discussions online and without a sounding board for dum questions it is easy for a beginner to make assumptions :)

The only reason the LEDs and resistors are that way round is that an LED bargraph only fits in the middle of the breadboard because of gaps in the power rails every 5 contacts (you can’t physically plug it in with all the cathodes to ground) so the resistors are placed between cathodes and ground - the fritzing diagram doesn’t show this. Electrically the order is irrelevant.

The current through each LED is about 15mA, since red LED’s drop about 1.8V, so the resistors have 5 - 1.8 = 3.2V across them, 3.2/220 = 14.5mA.

Yes, each pin is in parallel with the other pins (or to be more accurate the pin output transistors on the chip), so you sum the currents for each pin to get the current into the chip’s power pin(s). (The microcontroller uses some current to run the code too)

To be strictly accurate for a given pin the series circuit involves the output transistor as well as the LED and resistor - the output transistor is only a few tens of ohms or something like that for the 328 microcontroller - this small resistance is usually conveniently ignored in calculations.

If you were to measure the output voltage on one of the pins driving an LED like this it would be a bit less than 5.0V because of this “output” resistance. The larger the current load on a pin the more its voltage will “droop”. The absolute maximum current you should “sink” (or source) from a pin is 40mA - in practice this means don’t go above 30mA. The output transistors overheat if too much current goes through them and ultimately the chip fails.