Code: Select all
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) buttonA=23 buttonB=24 GPIO.setup(buttonA,GPIO.IN,pull_up_down=GPIO.PUD_UP) GPIO.setup(buttonB,GPIO.IN,pull_up_down=GPIO.PUD_DOWN) print (GPIO.input(buttonA)) print (GPIO.input(buttonB))
So my understanding is that setting up the button for GPIO23 wired to ground, I should be using PUD_UP to pull the voltage up to 3.3V. so by default I should get a reading of 1 when the button isn't pressed, and a reading of 0 when the button IS pressed.
Alternatively, GPIO24 wired to the 3.3v should be using PUD_DOWN, and give me a reading of 0 by default, and a reading of 1 when I press the button?...
So I would expect the reading from GPIO24 to be 0.... but how come I don't see 1 for the first print statement?
Just to go further, I actually had if statements coded out after that actually printed the status of the button, those didn't do anything and I'd constantly get a reading of 0 regardless.
Leading me to wonder if my gpio is even working for buttons. I say buttons specifically because I hooked up LED's to these and they seem to work fine.