Software guy here, first time doing hardware.

Here is my breadboard setup (yellow is GPIO-8, green is ground):

enter image description here

Here is my Python:

import RPi.GPIO as GPIO
from time import sleep


button = 8

GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    while True:
        output = GPIO.input(button)


This yields 1 ... 1 ... etc...

When I press the button, it doesn't change to 0. But, the LED turns on, which tells me that the circuit is working. Why isn't it triggering the 0 on the script?

  • Try this move the button so it straddles the groove in the center of the breadboard, then connect the resistor and LED to diagonally opposite corners of the button. Also, you will have an easier time debugging things if you use red and black for power and ground (instead of orange and green both used for ground in this case). Also, you are using output as a variable name for an input value (that can get confusing quickly). You can even eliminate the orange wire if you use the LED to connect to the ground rail. Aug 11, 2017 at 18:37
  • You are using a pull up resistor (internal on the Pin), but the pin is not connected to ground so how is the button ever expected to be low? The way you have it wired you are using the switch like a light switch. Aug 11, 2017 at 18:44
  • @SteveRobillard Ok, yeah, something about that seemed weird (again, not a hardware guy), Yes it is wired like a light switch. So should it go like this: 3v power -> Resistor -> Button -> jumper to GPIO pin -> Ground ?
    – M Leonard
    Aug 11, 2017 at 18:50
  • It depends what are you trying to do? Aug 11, 2017 at 18:58
  • @SteveRobillard I want 'something' to happen when the button is pressed. So basically, GPIO.input(button) == False (or 0) until the button is pressed, and: GPIO.input(button) == True or (1)
    – M Leonard
    Aug 11, 2017 at 18:59

1 Answer 1


You are mixing your metaphors. So to speak.

Either light up the LED (using an output), or use the GPIO as an input. Which is to say, if you want to detect the switch input, then remove the LED and connect the red wire directly to the switch. You could also wire the LED in parallel with the switch, but that would simply tell you when you were pressing the switch, which presumably you already know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.