-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbell.py
31 lines (29 loc) · 1.09 KB
/
bell.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#------------------------------------------------------------------
#
# WHO IS AT MY DOOR
# =================
#
# This program uses a camera, a pushbutton switch, and a relay
# connected to a Raspberry Pi 5. The camera is positioned outside
# the door to capture an image of who is outside. Pressing the
# button activates the relay for 5 seconds, then takes a picture
# and sends it to a smartphone via Bluetooth.
#
# Program: doorbell.py
# Author : Biswadeep Roy
#--------------------------------------------------------------------
from gpiozero import LED, Button
from time import sleep # Import sleep function from time library
import os
button = Button(20) # Button connected to GPIO pin 20
relay = LED(21) # Relay connected to GPIO pin 21
relay.off()
while True:
sleep(1)
if button.is_pressed: # Check if the button is pressed
relay.on() # Turn on the relay for 5 seconds
sleep(5)
relay.off()
os.system("obexftp --nopath --uuid none --noconn --bluetooth 50:50:A4:0F:62:3F --channel 12 -p door.jpg")
else:
relay.off()