Advertisement
Masoko

orvibo.s20 + MotionSensor py

Aug 23rd, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. import time
  2. from gpiozero import MotionSensor
  3. from orvibo.s20 import S20 #https://github.com/happyleavesaoc/python-orvibo
  4.  
  5. if __name__ == "__main__":
  6.         s20 = S20("192.168.0.113")
  7.         onaftermotion = 150
  8.         pir = MotionSensor(14)
  9.         while True:
  10.                 time.sleep(0.5)
  11.                 if pir.motion_detected:
  12.                         print("Motion detected!")
  13.                         try:
  14.                                 s20.on = True
  15.                                 print(time.ctime())
  16.                                 pir.wait_for_no_motion()
  17.                                 print("No Motion detected!")
  18.                                 print(time.ctime())
  19.                                 time.sleep(onaftermotion)
  20.                                 s20.on = False
  21.                         except:
  22.                                 pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement