door.py updates
This commit is contained in:
parent
0d3bb1f469
commit
5b1adee3ad
8
door.py
8
door.py
@ -18,14 +18,16 @@ PIN_17 = 17
|
||||
PIN_18 = 18
|
||||
|
||||
# Set GPIO
|
||||
GPIO.setup(PIN_17, GPIO.IN)
|
||||
GPIO.setup(PIN_18, GPIO.OUT)
|
||||
result_17 = GPIO.setup(PIN_17, GPIO.IN)
|
||||
result_18 - GPIO.setup(PIN_18, GPIO.OUT)
|
||||
|
||||
|
||||
while True:
|
||||
if GPIO.input(PIN_17) == GPIO.HIGH:
|
||||
print("Puerta abierta")
|
||||
client.publish("iiot/"+ myhost +"/door", result_17)
|
||||
GPIO.output(PIN_18, GPIO.HIGH) # Luz Roja encendida
|
||||
else:
|
||||
GPIO.output(PIN_18, GPIO.LOW)
|
||||
GPIO.output(PIN_18, GPIO.LOW)
|
||||
client.publish("iiot/"+ myhost +"/door", result_18)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user