anbindung an setstatus
This commit is contained in:
parent
a2a533ac65
commit
3d824a1c4c
1 changed files with 12 additions and 3 deletions
15
watchdoor.py
15
watchdoor.py
|
@ -6,13 +6,18 @@
|
|||
# mail: berhsi@web.de
|
||||
# desc: deamon who deals with edge detection at pin 18
|
||||
|
||||
import time
|
||||
import logging
|
||||
import RPi.GPIO as GPIO
|
||||
|
||||
loglevel = logging.INFO
|
||||
formatstring = '%(asctime)s: %(levelname)s: %(message)s'
|
||||
logging.basicConfig(format=formatstring, level=loglevel)
|
||||
import time
|
||||
import RPi.GPIO as GPIO
|
||||
try:
|
||||
from setstatus import SetStatus
|
||||
except Exception as e:
|
||||
logging.error('Cant import module setstatus')
|
||||
logging.error('Error: {}'.format(e))
|
||||
|
||||
|
||||
GPIO.setmode(GPIO.BOARD) # kind of enumeration
|
||||
GPIO.setup(18, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) # pin 18 (GPIO 24)
|
||||
|
@ -25,9 +30,13 @@ def voltage_changed(channel):
|
|||
if GPIO.input(channel) == GPIO.HIGH:
|
||||
# door closed -> pin hight
|
||||
logging.info('Pin high triggered - Space closed')
|
||||
s = SetStatus()
|
||||
s.run(0)
|
||||
else:
|
||||
# door open -> pin low
|
||||
logging.info('Pin low triggered - Space is open')
|
||||
s = SetStatus()
|
||||
s.run(1)
|
||||
|
||||
def main():
|
||||
'''
|
||||
|
|
Loading…
Reference in a new issue