door.py updates

This commit is contained in:
Adolfo Delorenzo 2024-07-05 09:12:03 -06:00
parent 0d3bb1f469
commit 5b1adee3ad

View File

@ -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)