Advertisement
Jim421616

pir2

Jul 23rd, 2018
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3. from subprocess import call
  4.  
  5. GPIO.setwarnings(False)
  6. GPIO.setmode(GPIO.BOARD)
  7. GPIO.setup(11, GPIO.IN)
  8. while true:
  9. i = GPIO.input(11)
  10. if i ==0:
  11. print("Screen off", i)
  12. call("vcgencmd display_power 0")
  13. time.sleep(1)
  14. elif i ==1:
  15. print("Screen on", i)
  16. call("vcgencmd display_power 1")
  17. time.sleep(30)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement