I have a GPIO button set on pin 23 of a Raspberry Pi 3 and I would like when the button is pressed for it to execute another python script. When I run the initial program, it will print "Button Pressed", but it will not execute the second program. (I did ensure the permissions are set in the program.) Thank you very much for your help!
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import subprocess
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(23)
if input_state == False:
print('Button Pressed')
subprocess.call('/home/pi/Downloads/PuttingItAllTogether.py', shell=True)
time.sleep(0.2)
/home/pi/Downloads/PuttingItAllTogether.pyscript produces output? Have you checked the exit status of the script (this is the return value ofsubprocess.call)? - larskssubprocess.call. Save that in a variable and print it out, as inreturnval = subprocess.call(...)followed by aprintstatement. - larsks