import RPi.GPIO as GPIO # Import library for GPIO (pin) access GPIO.setmode(GPIO.BOARD) # Specify that we use the BOARD numbers (pin numbers 1-26 on the connector) GPIO.setwarnings(False) # Disable the warning "This channel is already in use" import time GPIO.setup(22, GPIO.IN) # Configure pin 22 as an input (IN) print('I am waiting that you press the button...') while True: x = GPIO.input(22) # Read pin 22 if x == 0: # if the button is pressed... break # ... the break statements terminates the while loop time.sleep(0.01) # wait 10ms before checking pin 22 again print('Button pressed!')