Hi,
I studyed the documentation of pifacedigitalio, but do not have a clue how to program the below script.
When "pfd.input_pins[0].value == 1" changes from 0 to 1, I just want the program to run if the input changes to 1, not when it`s 1.
With SPS programing I would make a one shot of pfd.input_pins[0].value == 1.
The reason behind is that I want the subprocess.Popen(["/bin/myscript"]) only to be run once at the change of the input.
How do I do it with pifacedigital?? Any body has a sample code for this.
#!/usr/bin/python
import time
import subprocess
from subprocess import Popen
import pifacedigitalio
from time import sleep
pfd = pifacedigitalio.PiFaceDigital() # creates a PiFace Digital object
def input_pins[0](event):
event.chip.pins[0].value()
listener = pifacedigitalio.InputEventListener(chip=pfd)
listener.register(0, pifacedigitalio.IODIR_FALLING_EDGE, input_pins[0])
listener.register(0, pifacedigitalio.IODIR_RISING_EDGE, input_pins[0])
while(True):
sleep(0.1)
if pfd.input_pins[0].value == 1:
subprocess.Popen(["/bin/myscript"])
- Posts: 34
- Joined: Tue Apr 08, 2014 5:06 pm