I am starting in the programming with Python and I have come across a problem .... I want to make an infinite loop which comes out if I press the "s" option or if the raspberry button is activated. This is what I programmed, but it does not work correctly, any ideas?
import RPi.GPIO as gpio gpio.setmode(gpio.BCM) def prueba() boton=12 gpio.setup(boton, gpio.IN, gpio.PUD_UP) salir='n' while True: print ("para salir puse s: ") salir=input() if salir =='s': return 0 break if gpio.input(boton)==gpio.HIGH: return 1 break while True: if prueba() == 1 print("Ha pulsado s") if prueba() == 0 print("Ha pulsado boton")
Edit: The problem is in the While loop, since I have the feeling that using the input () function, it stays "stuck" and does not continue with the program until a value is entered by keyboard and although the button is pressed he is waiting for the keyboard.