Why does my LED light up when connected to 3v3 OR ground?


11 posts
by RonMcJack » Sat Jun 23, 2012 8:33 pm
Hi all,

Very confused as to why this can even happen? I've got the 3v3 line and the ground line attached to my breadboard and the GPIO lines attached too. If I attach a 330ohm resistor in series with an led to from the GPIO to the 3v3 line. It works when the python script is executed. If I swap the 3v3 line to the ground line and execute the script it works just the same? I thought LEDs don't work backwards? If they dont, which direction is the current going in both cases?
Posts: 5
Joined: Wed May 30, 2012 6:01 pm
by domesday » Sat Jun 23, 2012 9:02 pm
Can you post a photo ?
Posts: 258
Joined: Fri Oct 21, 2011 5:53 pm
Location: UK
by RonMcJack » Sat Jun 23, 2012 9:09 pm
https://dl.dropbox.com/u/342006/VIDEO0073.3gp I've got a video. Red wire is the 3v3 black is 0v and the green is the GPIO. The resistor leg is attached to the 3v3 line in the video but works when connected to the 0v line too.
Posts: 5
Joined: Wed May 30, 2012 6:01 pm
by domesday » Sat Jun 23, 2012 9:56 pm
Sorry can't see the video, perhaps someone else can look at it and figure out what is going on.
Posts: 258
Joined: Fri Oct 21, 2011 5:53 pm
Location: UK
by Gert van Loo » Sat Jun 23, 2012 10:47 pm
Let me guess: You have one side connected to the GPIO and the other to either 3V3 or ground.
Yes it will light both times. And if I tell you why you will say Duh! Of course.
I'll give you one tip: Do no switch the GPIO continuously high/low but manually high or low.
Check the LED orientation and check if it lights when the GPIO is low or when it is high.

Good luck in figuring it out!

(Post edit, can I plead others NOT to explain :-) )

-- Gert
User avatar
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1984
Joined: Tue Aug 02, 2011 7:27 am
by ksangeelee » Sat Jun 23, 2012 10:57 pm
Gert van Loo wrote:Good luck in figuring it out!

(Post edit, can I plead others NOT to explain :-) )

-- Gert


You edited just in time to prevent me spoiling all the fun. I'll wash my hands of this one!
Posts: 193
Joined: Sun Dec 25, 2011 5:25 pm
Location: Edinburgh, UK
by Gert van Loo » Sat Jun 23, 2012 11:08 pm
ksangeelee wrote:
Gert van Loo wrote:Good luck in figuring it out!

(Post edit, can I plead others NOT to explain :-) )

-- Gert


You edited just in time to prevent me spoiling all the fun. I'll wash my hands of this one!


My experience is that people learn a lot more if they experience the Oooohhh YYyeeeesssss!!!
User avatar
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1984
Joined: Tue Aug 02, 2011 7:27 am
by ksangeelee » Sun Jun 24, 2012 7:41 pm
Gert van Loo wrote:My experience is that people learn a lot more if they experience the Oooohhh YYyeeeesssss!!!


I agree with that statement, but because of the disparate nature of the Raspberry Pi documentation, and the incomplete datasheet, it's by no means obvious that a GPIO pin, when configured as an output, will source current when high, and sink current (act as ground) when low.
Posts: 193
Joined: Sun Dec 25, 2011 5:25 pm
Location: Edinburgh, UK
by Gert van Loo » Sun Jun 24, 2012 7:49 pm
ksangeelee wrote:
Gert van Loo wrote:My experience is that people learn a lot more if they experience the Oooohhh YYyeeeesssss!!!


I agree with that statement, but because of the disparate nature of the Raspberry Pi documentation, and the incomplete datasheet, it's by no means obvious that a GPIO pin, when configured as an output, will source current when high, and sink current (act as ground) when low.


I can't completely agree with that.
In general if you talk about an output pin of a device it can source as well as sink.
The only time an output pin can NOT source would be if it is an open collector in which case you should expect that to be clearly mentioned.

I have seen no more posts so I suggest you tell him why it lights BOTH ways.
(I thought about it but to have the LED light both ways you can't just move one pin between VCC and GND. You also must swap it around.)
User avatar
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1984
Joined: Tue Aug 02, 2011 7:27 am
by ksangeelee » Sun Jun 24, 2012 9:52 pm
RonMcJack wrote:https://dl.dropbox.com/u/342006/VIDEO0073.3gp I've got a video. Red wire is the 3v3 black is 0v and the green is the GPIO. The resistor leg is attached to the 3v3 line in the video but works when connected to the 0v line too.


Given that the ground rail plays no part in the circuit (since the GPIO pin is sinking the current through the LED), you might want to measure the voltage between what you think is ground and what appears to be 3v3 (video isn't clear enough to see the flat side of the LED).

Perhaps you've actually got 3v3 there too? That ribbon cable looks spliced and twisted, maybe you translated the pins incorrectly? In any case, that multimeter in the video background will confirm.
Posts: 193
Joined: Sun Dec 25, 2011 5:25 pm
Location: Edinburgh, UK
by Burngate » Mon Jun 25, 2012 8:38 am
My suggestion would be to put in a second LED with resistor, and connect one to each of the red and black.
If your red and black are really 3v3 and 0v, and the LEDs are the same way round (anode to green) then only one should blink.
If you turn one LED round they should blink alternately (or neither will light)
If you've mixed up the pins so that one of the red or black isn't what you think it is, then they'll blink synchronously.
Brain surgery is easier than psychoanalysis
User avatar
Posts: 2657
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK