0
Offline
Newbie
Karma: 0
Posts: 30
Arduino rocks
|
 |
« on: October 26, 2010, 11:40:53 am » |
Hi guys
This is a very beginner question that I couldn't seem to get a definitive answer to. So here goes...
I setup the following circuits with my Arduino... please could you explain to me why the one marked 'doesn't work' doesn't work.
1. (5V) ----- resistor ------ (+)LED(-) ------ GND (works)
2 . (5V) ----- (+)LED(-) ------ resistor(-) ------ GND (works)
3. (Pin D9) ------- resistor -----(+)LED(-) ---- GND (doesn't work)
4. (Pin D9) -------(+)LED(-) ----- resistor ---- GND (works)
(Note. I programmed the microcontroller to put pin digital 9 to HIGH.)
I'm confused as to where I need to place the resistor in circuits and other components. Also why does 1. work but not 3. seeing that the only difference is that the positive charge is coming from the digital pin 9?
Thanks in advance.
|
|
|
|
« Last Edit: October 26, 2010, 11:58:14 am by Ridd »
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19060
I don't think you connected the grounds, Dave.
|
 |
« Reply #1 on: October 26, 2010, 11:44:00 am » |
There is no reason, except perhaps the orientation of the diode, which you haven't shown.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 30
Arduino rocks
|
 |
« Reply #2 on: October 26, 2010, 11:58:29 am » |
I updated my original post.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 12
Posts: 2857
ruggedcircuits.com
|
 |
« Reply #3 on: October 26, 2010, 12:37:28 pm » |
It works, you just don't realize that it works  Really, there is no reason why if 4 works then 3 doesn't. Just check everything reaaallllly carefully and try again. -- The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 30
Arduino rocks
|
 |
« Reply #4 on: October 26, 2010, 01:13:24 pm » |
You are right  there must have been some connection issue somewhere. Interesting. But just in general... should the resistor go before or after the LED, in the above circuits? i.e. which is best practice and why.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 12
Posts: 2857
ruggedcircuits.com
|
 |
« Reply #5 on: October 26, 2010, 01:17:22 pm » |
It doesn't matter....I'd go 51% with the resistor closer to the Arduino pin. Just for safety's sake, if you mistakenly short something out the resistor has a better chance of protecting the pin from overcurrent. Suppose you mistakenly short out the LED anode to GND. In configuration (4) that you drew you'd be shorting out the Arduino pin and quite possibly damaging the microcontroller. In configuration (3) the pin is protected by the resistor. Of course, you could always short the "wrong" end of the resistor to ground too, so it's no guarantee of anything..... -- The Quick Shield: breakout all 28 pins to quick-connect terminals
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 30
Arduino rocks
|
 |
« Reply #6 on: October 26, 2010, 02:05:35 pm » |
Great. Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Phoenix, Arizona USA
Offline
Faraday Member
Karma: 27
Posts: 5079
Where's the beer?
|
 |
« Reply #7 on: October 26, 2010, 04:07:38 pm » |
But just in general... should the resistor go before or after the LED, in the above circuits? i.e. which is best practice and why My take on this is 1 or 3 - here's why: It is common "sense" to envision current as flowing from high potential (voltage) to ground (ie, from positive to negative). In reality, this isn't true at all (and nothing really "flows" anyhow), but the visualization is easy to see. Resistors are used to decrease current in a circuit (thus lowering the current through the LED in this case), so from the "flow" perspective above, it makes more sense that the current flows out the pin, goes thru the resistor (and lowering current), then thru the LED, then to ground. Once again, in reality this isn't how it actually works, and it ultimately doesn't matter which side the resistor is on, as RuggedCircuits has already noted... 
|
|
|
|
|
Logged
|
|
|
|
|
SW Scotland
Offline
Edison Member
Karma: 6
Posts: 1053
Arduino rocks
|
 |
« Reply #8 on: October 26, 2010, 05:21:36 pm » |
One of the analogies for electrical systems is plumbing, where we have pipe (wire), water(current), reservoirs, tanks or rivers (batteries or capacitors) and taps or faucets (resistors).
To control flow of water you always have the tap in the line before the appliance. Hence resistor goes before LED.
Jack
|
|
|
|
|
Logged
|
|
|
|
|
SE USA
Offline
Faraday Member
Karma: 33
Posts: 3621
@ssh0le
|
 |
« Reply #9 on: October 26, 2010, 06:11:43 pm » |
but again it does not really matter, to use plumbing if you have a restrictive area (ie resistor) anywhere in the line the end result will be less flow
(besides water is a horrible analogy to electricity)
|
|
|
|
« Last Edit: October 26, 2010, 06:13:19 pm by Osgeld »
|
Logged
|
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #10 on: October 26, 2010, 06:28:02 pm » |
(besides water is a horrible analogy to electricity) Yes, because there is a big difference between being electrocuted and drowning.  No difference where you put the resistor in a series circuit. One of Kirchhoff's law says so. Probably a friend of Dr. Ohm. Lefty
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 30
Arduino rocks
|
 |
« Reply #11 on: October 27, 2010, 11:43:27 am » |
Lol.
Thanks guys. I would also agree that logically 1 & 3 are best practice.
|
|
|
|
|
Logged
|
|
|
|
|
|