-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLedDoor.py
More file actions
45 lines (40 loc) · 1.21 KB
/
LedDoor.py
File metadata and controls
45 lines (40 loc) · 1.21 KB
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
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
debug=False
import time
import RPi.GPIO as GPIO
import ConfigParser
config=ConfigParser.ConfigParser()
config.read('/home/pertneer/Desktop/config.ini')
GPIO.setwarnings(False)
if (GPIO.getmode() == 10) or (GPIO.getmode() == None):
GPIO.setmode(GPIO.BCM)
doorOpenPin=int(config.get('Pins','doorOpenPin'))
doorClosePin=int(config.get('Pins','doorClosePin'))
if(debug):
print doorClosePin
print doorOpenPin
greenPin=int(config.get('Led','greenPin'))
redPin=int(config.get('Led','redPin'))
if(debug):
print redPin
print greenPin
GPIO.setup(doorOpenPin, GPIO.IN, GPIO.PUD_UP)
GPIO.setup(doorClosePin, GPIO.IN, GPIO.PUD_UP)
GPIO.setup(greenPin,GPIO.OUT)
GPIO.setup(redPin,GPIO.OUT)
while True:
if ((GPIO.input(doorOpenPin) == 0) or (GPIO.input(doorClosePin) == 0)):
if(debug):
print GPIO.input(doorOpenPin)
print GPIO.input(doorClosePin)
GPIO.output(greenPin, True)
GPIO.output(redPin, False)
time.sleep(3)
else:
if(debug):
print GPIO.input(doorOpenPin)
print GPIO.input(doorClosePin)
GPIO.output(greenPin, False)
GPIO.output(redPin, True)
time.sleep(3)
GPIO.cleanup()