-
Notifications
You must be signed in to change notification settings - Fork 0
/
relePir.py
36 lines (30 loc) · 1004 Bytes
/
relePir.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
32
33
34
35
import RPi.GPIO as GPIO
import time
import os
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.IN)
hora = time.strftime("%H:%M:%S")
fecha = time.strftime("%d/%m/%y")
#GPIO.setup(24, GPIO.OUT)
try:
time.sleep(2)
print fecha, hora,("|==>: Iniciando.")
#print(time.strftime("%H:%M:%S"))
#print("iniciando")
while True:
if GPIO.input(7):
#GPIO.output(24, True)
#time.sleep(0.5)
#GPIO.output(24, False)
print fecha, hora, ("|==>: Movimiento detectado,foco encendido.")
os.system('sh /home/pi/scripts/focoOn.sh')
time.sleep(5.5)
time.sleep(0.1)
#os.system('sh /home/pi/scripts/focoOff.sh')
# print("estado original")
else:
os.system('sh /home/pi/scripts/focoOff.sh')
print fecha, hora, ("|==>: Foco apagado.")
time.sleep(5.5)
except:
GPIO.cleanup()