Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import time
- import os
- #adjust for where your switch is connected
- buttonPin = 999 # change 999 to the GPIO pin number of the positive charge
- while True:
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(buttonPin,GPIO.IN)
- #assuming the script to call is long enough we can ignore bouncing
- #
- time.sleep(2)
- print GPIO.input(buttonPin)
- if (GPIO.input(buttonPin)):
- print GPIO.input(buttonPin)
- #this is the script that will be called (as root)
- #when using a USB webcam
- #os.system("fswebcam -r 960x720 -d /dev/video0 /home/pi/Desktop/Doorbell/webcam.jpg")
- #when using the Raspberry Pi webcam
- #os.system("raspistill -h 300 -w 400 -n -o /home/pi/Desktop/Doorbell/webcam.jpg")
- #print "Photo captured."
- #call send the email message with the photo attached
- #os.system("python /home/pi/Desktop/Doorbell/sendnotify.py")
Advertisement
Add Comment
Please, Sign In to add comment