I have a raspberry pi wich i'm using to monitor an input from the GPIO ports, to do this i need to run an infinite loop.
When i receive a LOW in my input i want to execute a system command usint subprocess.call. The problem is that it executes this command for as long as the input is receiving LOW i have tried this to make it execute only once but i can't make it work.
while 1:
if (GPIO.input(11) != GPIO.HIGH ):
puerta_abierta = 1
if(puerta_abierta == 1 ):
call(["mpg123", "file.mp3"])
puerta_abierta = 0
else:
puerta_abierta = 0