elias4444
Posts: 15
Joined: Sat Dec 26, 2015 7:28 pm

I don't understand GPIO states

Wed Jul 29, 2020 4:36 pm

I've always been a software person, but was always fascinated with the hardware side of things. So I bought myself a couple of electronics kits for RPi and am trying to learn how all of this works.

Before I even begun, I read up on everything I could find so I wouldn't ruin my RPi. And, right out of the gate, I ran into something I didn't understand. Each of these electronics kit wire the first "blinking LED light" tutorial differently.

Kit #1 wires from GPIO17, to resistor, to LED, to GND.

Kit #2 wires from 3V3, to resistor, to LED, to GPIO17.

So, in Kit #1, when GPIO17 is set to HIGH, I'm assuming GPIO17 is then providing the necessary 3.3v to turn on the circuit. When it's set to low, there's no voltage, so it turns off. I get this.

Where I become confused is with Kit #2. If the 3V3 pin is providing constant voltage, and GPIO17 is set to LOW, the LED comes on as expected (I'm assuming GPIO17 is acting as a GND in this case?). But why does settings GPIO17 to HIGH turn it off? If the pin acts the same as the setup in Kit#1, how is providing 3.3v at both ends of the circuit a good thing?

I'm guessing the GPIO pins are somehow sensing what they have to do in each case? If so, what are they doing exactly? I'd really like to understand this for future projects.

Any help is greatly appreciated!

User avatar
davidcoton
Posts: 5083
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: I don't understand GPIO states

Wed Jul 29, 2020 4:55 pm

elias4444 wrote: ...
Where I become confused is with Kit #2. If the 3V3 pin is providing constant voltage, and GPIO17 is set to LOW, the LED comes on as expected (I'm assuming GPIO17 is acting as a GND in this case?). But why does settings GPIO17 to HIGH turn it off? If the pin acts the same as the setup in Kit#1, how is providing 3.3v at both ends of the circuit a good thing?

I'm guessing the GPIO pins are somehow sensing what they have to do in each case? If so, what are they doing exactly? I'd really like to understand this for future projects.
If both ends of the circuit are at the same voltage, no current can flow, so the LED is off. Why would it hurt to keep the whole circuit (LED+resistor) at 3V3? The only problem is if there is an accidental short to ground, or 5V -- but then if the whole circuit is at 0V, a short to 3V3 or 5V would equally cause issues.

There is no need to the GPIOs to sense anything -- it can be done, it's how many older fire or intruder alarm systems work (the controller senses, not necessarily a GPIO). GPIOs only sense when set as inputs -- but that's a different topic.
Signature retired

elias4444
Posts: 15
Joined: Sat Dec 26, 2015 7:28 pm

Re: I don't understand GPIO states

Wed Jul 29, 2020 4:59 pm

Silly me. After writing all of that out, I think I may have answered my own question.

By making both the cathode and anode a positive voltage, you stop the flow of electricity. :roll:

If I'm wrong, please let me know. If I'm right, sorry for wasting your time. :oops:

elias4444
Posts: 15
Joined: Sat Dec 26, 2015 7:28 pm

Re: I don't understand GPIO states

Wed Jul 29, 2020 5:01 pm

davidcoton wrote:
Wed Jul 29, 2020 4:55 pm
If both ends of the circuit are at the same voltage, no current can flow, so the LED is off. Why would it hurt to keep the whole circuit (LED+resistor) at 3V3? The only problem is if there is an accidental short to ground, or 5V -- but then if the whole circuit is at 0V, a short to 3V3 or 5V would equally cause issues.

There is no need to the GPIOs to sense anything -- it can be done, it's how many older fire or intruder alarm systems work (the controller senses, not necessarily a GPIO). GPIOs only sense when set as inputs -- but that's a different topic.
Thank you for verifying this. Sorry I posted a reply at the same time.

Return to “Beginners”