The Button script has the PiCam script embedded. So Button script says: On detecting pin x run PiCam script. No problems all good.
What I'd like to add is some code that says on second button push stop script. So one button, push once runs script, push a second time stop script and then loop that I suppose so that each subsequent push starts or stops the script until shutdown of either Pi or script.
So far I run the following which although may not be perfect seems to work. Any help would be greatly appreciated.
Code: Select all
import RPi.GPIO as GPIO Import time import subprocess GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIOIN, pull_up_down=GPIO.PUD_UP) while True: input_state = GPIO.input(23) if input_state == False: subprocess.call("/home/pi/securipi-rpicamtd.sh", shell=True) time.sleep(0.2)