Created
September 8, 2016 11:10
-
-
Save jezman/4083ffcf05235be41ae6269efa9e569d to your computer and use it in GitHub Desktop.
The script for motion app. Executed when a motion frame is detected. Writes the sensor status.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import RPi.GPIO as GPIO | |
from time import sleep | |
pir_sensor = 18 | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(pir_sensor, GPIO.IN) | |
fl = open('/home/user/sensor_status', 'w') | |
i = 0 | |
current_state = 0 | |
while i < 6: | |
current_state = GPIO.input(pir_sensor) | |
fl.write('%s' % (current_state)) | |
sleep(1) | |
i += 1 | |
GPIO.cleanup(18) | |
fl.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment