from dht import DHT22
from machine import Pin
from time import sleep
l1 = Pin(0,Pin.OUT)
l2 = Pin(3,Pin.OUT)
bot = Pin(20,Pin.IN,Pin.PULL_UP)
dht = DHT22(28)
while True:
if bot.value() == 0:
try:
dht.measure()
except:
print("erro")
leitura = input("(1)umidade (2)temperatura")
sleep(2)
if leitura == "1":
sensor = dht.humidity()
l1.on()
elif leitura == "2":
sensor = dht.temperature()
l2.on()
else:
sensor = "erro"
print(sensor)
l1.off()
l2.off()
else:
print("precione o botão")
sleep(2)