from machine import Pin
from machine import ADC
from dht import DHT22
from time import sleep
azul = Pin(2, Pin.OUT)
led = Pin(25, Pin.OUT)
botver = Pin(9, Pin.IN, Pin.PULL_UP)
botama = Pin(13, Pin.IN, Pin.PULL_UP)
sensor = DHT22(Pin(21))
pot = ADC(28)
valor = 0
while True:
try:
sensor.measure()
H = sensor.humidity()
valor = pot.read_u16()
if botver.value() == 0:
print(H, "%")
led.on()
if H >=80:
print("Humidade segura")
else:
print("Alerta")
sleep (2)
elif botama.value() == 0:
print("Valor Potenciometro =", valor)
azul.on()
sleep(2)
else:
print("Aperte/segure o botão amarelo para ler o Potênciometro e Botão vermelho para ler a Humidade atual")
led.off(), azul.off()
sleep(1)
except:
print("Erro")
sleep(2)