from machine import Pin
from time import sleep
import dht
#objetos
Botao = Pin(5,Pin.IN,Pin.PULL_UP)
led01 = Pin(7,Pin.OUT)
led02 = Pin(27,Pin.OUT)
led03 = Pin(21,Pin.OUT)
led04 = Pin(16,Pin.OUT)
led05 = Pin(14,Pin.OUT)
sensor = dht.DHT22(Pin(28))
while True:
if Botao.value()== 0:
try:
sensor.measure()
temp = sensor.temperature()
umi = sensor.humidity()
if (temp < 10) and (umi< 20):
led01.on()
elif (temp >= 10) and (temp < 20) and (umi< 40) and (umi >= 20):
led02.on()
elif (temp >= 20) and (temp < 40) and (umi >= 40) and (umi < 60):
led03.on()
elif (temp >= 40) and (temp < 60) and (umi >= 60) and (umi < 80):
led04.on()
elif (temp >= 60) and (temp < 80) and (umi >= 80) and (umi < 100):
led05.on()
else:
led01.off()
led02.off()
led03.off()
led04.off()
led05.off()
except:
print ("erro")
else:
led01.off()
led02.off()
led03.off()
led04.off()
led05.off()