Checkmark

wait_doorbell

May 30th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3. import os
  4.  
  5. #adjust for where your switch is connected
  6. buttonPin = 999  # change 999 to the GPIO pin number of the positive charge
  7.  
  8. while True:
  9.     GPIO.setmode(GPIO.BCM)
  10.     GPIO.setup(buttonPin,GPIO.IN)
  11.     #assuming the script to call is long enough we can ignore bouncing
  12.     #
  13.     time.sleep(2)  
  14.     print GPIO.input(buttonPin)
  15.     if (GPIO.input(buttonPin)):
  16.         print GPIO.input(buttonPin)
  17.         #this is the script that will be called (as root)
  18.         #when using a USB webcam
  19.         #os.system("fswebcam -r 960x720 -d /dev/video0 /home/pi/Desktop/Doorbell/webcam.jpg")
  20.        
  21.         #when using the Raspberry Pi webcam
  22.         #os.system("raspistill -h 300 -w 400 -n -o /home/pi/Desktop/Doorbell/webcam.jpg")
  23.         #print "Photo captured."
  24.        
  25.         #call send the email message with the photo attached
  26.         #os.system("python /home/pi/Desktop/Doorbell/sendnotify.py")
Advertisement
Add Comment
Please, Sign In to add comment