Hi Robert, With the LED circuit (and all others) there is one little extra fact which seems obvious when it is pointed out, but is quite important: If you put 9V across a circuit, all of the 9 volts will be "dropped" somewhere in it. We use the resistor to "eat up" this voltage and set the current. So if you look at the LED/resistor circuit, it has 9V across it. The LED wants to drop 1.6V, which leaves 7.4V dropped across the resistor. Now, to ensure we don't kill the LED with too much current, we need to limit the current - this is where Ohm's law comes in. Say we want to run the LED at 20mA (0.02A), we know from the specs that it will drop 1.6V therefore the resistor has to be sized to drop the remaining 7.4V at the required current of 20mA: V = IR or R = V/I R = (9-1.6) / 0.02 R = 370 ohms. 390 ohms is the next "common" size so we would use it. Giving us: 7.4/390 = 0.019 A (approx) Note that 20mA is probably not needed, I tend to run LEDs at 10mA, and they are heaps bright enough in most cases. Now, lets look at the power dissipated by the resistor. (think of the "dropped" voltage becoming heat) P = IV and V = IR Therefore, substituting we get P = I^2R (I power of 2, ie: squared) or P = V^2/R Because we know all the values for V, I and R we can use any one. P = IV = 0.019 * 7.4 = 0.14 Watts. So a common 1/4 watt resistor will be fine. And if you calculate with the other formulas we get the same answer. As for connecting to a PIC, you can use what ever is convenient! :) A pic is able to sink (to ground) or source (from Vcc) 20mA current on its pins. (There are exceptions - the "open collector" outputs for instance can only sink current). However other microcontrollers are often not able to source as much as they can sink. For instance, they may be able to sink 20mA, but only source 5mA. Therefore alot of people (myself included) tend to have the led wired so you complete the "ground" connection with the PIC pin ie sourcing current. Just watch out - you will need to recalculate the resistor value, because you have a lower voltage driving the LED - the PIC need a 5V supply. I'll leave that up to you to do. Note that you should be powering the LED off the 5V if you are using the PIC to switch it - you can't put 9V onto its pins! You would need to use a transistor to drive the LED (or other device) if you wanted to run it from a different voltage, but that's another story :) The only thing to watch with this is you have to "invert" your thinking in the code - you set the pin LOW (0) to turn it on, and HIGH (1) to turn it off. There is another complication - the PIC can only support a maximum current per "PORT" so if you have all the pins on a port driving LEDs and they are all on, you may be over this limit - check the datasheet, from memory the limit is about 100mA, but I could be wrong. Assuming it is, you are right on the limit with 5 LEDs @ 20mA each! This is one reason I tend to use 10mA and sometimes even 5mA for LEDs.. In normal interior lighting this will be plenty bright enough. Oh also here is a nice way to remember Ohm's law and the Power formulas: (ASCII Art, use a fixed width font) / \ / V \ /--+--\ / I | R \ /____|____\ draw as a triangle, then you cover the one you don't know to get the formula for it. for instance, if you want to know the voltage, you cover V and read I*R, if you want to know current, you cover I and read V/R. Same for Power: / \ / P \ /--+--\ / I | V \ /____|____\ Hope this helps, Cheers, Ash. --- Ashley Roll Digital Nemesis Pty Ltd www.digitalnemesis.com Mobile: +61 (0)417 705 718 > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Robert Wade > Sent: Saturday, 14 September 2002 1:03 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: [EE]: voltage and [PIC]: ground vs voltage connection > > I have an LED that needs 1.6Volts to light up. and I have a 9 > volt battery. now I see every calulation to go from Volts, watts, > resistance, amps, etc.. > What I have not seen is what the end result is. It I have a 9 > volt battery and a 40ohm resistor then I end up with a amp of 0.225. now > if I take the amps and multiply it by 40ohm I end up with 9 volts. Ok I > think I got Ohms Law. Now how do I get the value of the Volts after the > resistor is applied to the line ? > > Ok now is it better to have a PICs chip connected to the > ground pin of an > LED or is it best to have the PIC control the voltage to the > device? will > either solution result in a voltage leak or drain? -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads