File size: 837 Bytes
01b5b36 |
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 32 33 34 35 |
# -*- coding: utf-8 -*-
"""kostromaDM.195
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1pfaAm7oNbuib2cvOfdmeqpF6F5COtI-1
"""
import RPi.GPIO as GPIO
import ADC0834
from time import sleep
GPIO.setmode(GPIO.BCM)
motionPin=23
buzzPin=26
GPIO.setup(buzzPin,GPIO.OUT)
GPIO.output(buzzPin,GPIO.HIGH)
GPIO.setup(motionPin,GPIO.IN)
ADC0834.setup()
sleep(2)
try:
while True
motion=GPIO.input(motionPin)
lightVal=ADC0834.getResult(0)
print('Light Value', lightVal,'Motion: ',motion)
sleep(.1)
if motion=1 and lightVal<=140:
GPIO.output(buzzPin,GPIO.LOW)
print('INTRUDER ALERT: Deploy Countermeasures!')
else:
print('All Clear on the Eastern Front')
except KeyboardInterrupt:
sleep(.25)
GPIO.cleanup()
print('GPIO Ready To Perform') |