forked from Mboukhal/RaspberryGate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpioControl.py
45 lines (34 loc) · 986 Bytes
/
gpioControl.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
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python
import RPi.GPIO as GPIO
from time import sleep
import os
RELAY_1 = 14 # IN relay
RELAY_2 = 15 # OUT relay
def openGate( relay ):
if os.getenv("RELAY_TYPE") == "GSRT":
relayOn = GPIO.LOW
relayOff = GPIO.HIGH
elif os.getenv("RELAY_TYPE") == "PSRT":
relayOn = GPIO.HIGH
relayOff = GPIO.LOW
GPIO.output( relay, relayOn )
sleep( 1 )
GPIO.output( relay, relayOff )
def initGpio():
if os.getenv("RELAY_TYPE") == "GSRT":
relayOff = GPIO.HIGH
elif os.getenv("RELAY_TYPE") == "PSRT":
relayOff = GPIO.LOW
try:
GPIO.setwarnings(False)
try:
GPIO.cleanup()
except:
pass
GPIO.setmode( GPIO.BCM )
GPIO.setup( RELAY_1, GPIO.OUT )
GPIO.output( RELAY_1, relayOff )
GPIO.setup( RELAY_2, GPIO.OUT )
GPIO.output( RELAY_2, relayOff )
except:
pass