#Ejercicio 5: Control de ventilador inteligente por temperatura + botón de prioridad
#Nombre: Zhayanka Pilay Beltrán
from machine import Pin, ADC
import time
pot = ADC(26)
ventilador =Pin(0, Pin.OUT)
boton =Pin(28, Pin.IN, Pin.PULL_DOWN)
while True:
valor_adc = pot.read_u16()
temperatura =(valor_adc/65535)*50
prioridad = boton.value()
if prioridad== 1:
ventilador.value(1)
elif temperatura >35:
ventilador.value(1)
elif temperatura <30:
ventilador.value(0)
print("Temp: {:.1f} °C | Prioridad Manual: {} | ventilador:{}".format(
temperatura, prioridad, ventilador.value()))
time.sleep(0.5) # Wait for USB to become ready