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 PIN_18 = 18
# Set GPIO # Set GPIO
GPIO.setup(PIN_17, GPIO.IN) result_17 = GPIO.setup(PIN_17, GPIO.IN)
GPIO.setup(PIN_18, GPIO.OUT) result_18 - GPIO.setup(PIN_18, GPIO.OUT)
while True: while True:
if GPIO.input(PIN_17) == GPIO.HIGH: if GPIO.input(PIN_17) == GPIO.HIGH:
print("Puerta abierta") print("Puerta abierta")
client.publish("iiot/"+ myhost +"/door", result_17)
GPIO.output(PIN_18, GPIO.HIGH) # Luz Roja encendida GPIO.output(PIN_18, GPIO.HIGH) # Luz Roja encendida
else: else:
GPIO.output(PIN_18, GPIO.LOW) GPIO.output(PIN_18, GPIO.LOW)
client.publish("iiot/"+ myhost +"/door", result_18)