motion sensor raspberry Pi
motion sensor raspberry Pi
R2
Note: Either Buzzer or LED can be interfaced to GPIO 20 pin. Both cannot be connected
simultaneously.
GPIO Pin Connection for PIR, Buzzer and LED:
Pin on Kit Pins on Raspberry Pi
GPIO Pins Pin Nmber
Buzzer/ LED GPIO 20 38
PIR Sensor GPIO 21 40
+3.3V 1
(Already Connected)
+ 5V
(Already Connected)
GND
(Already Connected)
1
Procedure:
Note: The Raspbianoperating system comes with Python already installed in it.
1. Setting up the circuit:
a. Turn OFF the Raspberry Pi while building/connecting the circuit
board/components according to diagram.
b. Then turn the Raspberry Piand check the Raspbian OS loaded properly or not. If
not then check the circuit connection again.
2. Python Programnming: Python via IDLE
a Start Raspberry Pi in desktop mode, open the Applications Menu in the top left of
your screen, and navigate to Programming> Python 3 (IDLE) /. This willopen
the Python shell.
AoCessories
Graphncs PytoH 2(0.E)
Hip
Scratch
Preferences
Scrath 2
Run..
b. Write a program for PIR sensor and Buzzer interfacing with raspberry pi and
save as with pir.py
while True:
#when motion detected turn on BUZZ
if(GPIO.input(PIR_input):
GPIO.output(BUZZ, GPIO.HIGH)
else:
GPIO.output(BUZZ, GPIO.LOW)