Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1247

Python • Very simple gpiozero button code not working

$
0
0
I am utterly confused.

I'm using this code from gpiozero:

Code:

from gpiozero import Buttonbutton = Button(22)button.wait_for_press()print("The button was pressed!")
When I run it, it always, immediately says "The button was pressed!". Shouldn't it wait for me to press the button to print that?

I have a wire from pin 22 to one hole on my breadboard next to the button pin and one from the other side of the button to GND.
I tried multiple pins for the input, i tried multiple grounds.
I tried not connecting anything
I tried connecting the pins in the same row (that should have given me a button pressed notification immediately, but I was trying to check all the permutations)

What am i missing? sometimes the most obvious things are the hardest to see....
IMG_6405.jpg

Statistics: Posted by Blix666 — Sat Apr 05, 2025 10:56 pm



Viewing all articles
Browse latest Browse all 1247

Trending Articles