SHARE
TWEET

PIR.py

OhioJoe Dec 11th, 2017 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. import sys
  3. import time
  4. import RPi.GPIO as io
  5. import subprocess
  6. io.setmode(io.BCM)
  7. PIR_PIN = 8
  8. io.setup(PIR_PIN, io.IN)
  9. while True:
  10.     if io.input(PIR_PIN):
  11.         print("POWER ON")
  12.         subprocess.call("sudo /opt/vc/bin/tvservice -p && fbset -accel true",shell=True)
  13.         time.sleep(20)
  14.         print("POWER OFF")
  15.         subprocess.call("sudo fbset -accel false && /opt/vc/bin/tvservice -o",shell=True)
  16.     time.sleep(5)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top