Advertisement
silver2row

Motion Sensor

Aug 11th, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import Adafruit_BBIO.GPIO as GPIO
  2. import time
  3. #import tweepy
  4. #import os
  5. #import sys
  6.  
  7. GPIO.setup("P8_8", GPIO.IN)
  8. GPIO.setup("P8_12", GPIO.OUT)
  9.  
  10. while True:
  11.     GPIO.add_event_detect("P8_8", GPIO.FALLING)
  12.     if GPIO.event_detected("P8_8"):
  13.         GPIO.output("P8_12", GPIO.HIGH)
  14.         print("Motion Has Been Detected!")
  15.         time.sleep(2)
  16.     else:
  17.         GPIO.output("P8_12", GPIO.LOW)
  18.         print("No Intruders Yet!")
  19.         time.sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement