kostromaDM.195 / kostromadm_195.py
antitheft159's picture
Upload kostromadm_195.py
01b5b36 verified
raw
history blame contribute delete
837 Bytes
# -*- 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')