Upload kostromadm_195.py
Browse files- kostromadm_195.py +35 -0
kostromadm_195.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""kostromaDM.195
|
3 |
+
|
4 |
+
Automatically generated by Colab.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1pfaAm7oNbuib2cvOfdmeqpF6F5COtI-1
|
8 |
+
"""
|
9 |
+
|
10 |
+
import RPi.GPIO as GPIO
|
11 |
+
import ADC0834
|
12 |
+
from time import sleep
|
13 |
+
GPIO.setmode(GPIO.BCM)
|
14 |
+
motionPin=23
|
15 |
+
buzzPin=26
|
16 |
+
GPIO.setup(buzzPin,GPIO.OUT)
|
17 |
+
GPIO.output(buzzPin,GPIO.HIGH)
|
18 |
+
GPIO.setup(motionPin,GPIO.IN)
|
19 |
+
ADC0834.setup()
|
20 |
+
sleep(2)
|
21 |
+
try:
|
22 |
+
while True
|
23 |
+
motion=GPIO.input(motionPin)
|
24 |
+
lightVal=ADC0834.getResult(0)
|
25 |
+
print('Light Value', lightVal,'Motion: ',motion)
|
26 |
+
sleep(.1)
|
27 |
+
if motion=1 and lightVal<=140:
|
28 |
+
GPIO.output(buzzPin,GPIO.LOW)
|
29 |
+
print('INTRUDER ALERT: Deploy Countermeasures!')
|
30 |
+
else:
|
31 |
+
print('All Clear on the Eastern Front')
|
32 |
+
except KeyboardInterrupt:
|
33 |
+
sleep(.25)
|
34 |
+
GPIO.cleanup()
|
35 |
+
print('GPIO Ready To Perform')
|