Advertisement
OhioJoe

PIR.py

Dec 11th, 2017
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement