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. (This is the gpio library currently mentioned by Raspberry Pi in their own documentation: Use GPIO from Python - https://www.raspberrypi.com/documentati ... rom-python )
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