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

Python • Re: stop loop with button press--raspberry pi and gpio

$
0
0
Hello, I am pretty new to python and coding, so this may be a basic question, but how would I go about exiting a loop with a button press via gpio input?

What I want is once a condition is triggered (will eventually be triggered by sensors, but currently for testing and learning is triggered by a button press via gpio input) a led will flash on and off until a button via gpio input is pressed.

[ ... ]

Thanks to all that help me figure this out!!

I suggest considering shifting your loyalty from RPi.GPIO to the alternative gpiozero Python library.

gpiozero comes supplied with routines that watch for changes in gpio state and let you take appropriate actions.

Examples -
https://gpiozero.readthedocs.io/en/stab ... tml#button

Statistics: Posted by B.Goode — Thu Nov 14, 2024 10:48 am



Viewing all articles
Browse latest Browse all 4906

Trending Articles