I'm trying to pause code execution till a button is pressed and this is what I came up with. I have not tested this but can anyone tell me if this is the right way to go about it? Button 'pressed' is active HIGH on the GPIO pin.
import RPi.GPIO as GPIO
GPIO.setmode (GPIO.BOARD)
#BCM uses the GPIO numbers while BOARD uses the actual pin number
GPIO.setwarnings (False)
while GPIO.input(17) == False:
pass
print ("Button 1 pressed")
GPIO.cleanup()
I have not tested this... why not? ... that is all part of research that you should have done before posting your question