from machine import Pin
from time import sleep
import dht
sensor = dht.DHT22(Pin(15))
ledR = Pin(23, Pin.OUT)
ledG = Pin(22, Pin.OUT)
ledB = Pin(21, Pin.OUT)
def set_color(r, g, b):
ledR.value(r)
ledG.value(g)
ledB.value(b)
print("HOLA\n")
set_color(1, 0, 1) #luz magenta
sleep(2)
while True:
sensor.measure()
temp = sensor.temperature()
hum = sensor.humidity()
print('Temperatura:', temp, '°C | Humedad:', hum, '%')
if temp < 5:
set_color(0, 0, 1)
elif temp < 18:
set_color(0, 1, 1)
elif temp < 26:
set_color(0, 1, 0)
elif temp < 35:
set_color(1, 1, 0)
else:
set_color(1, 0, 0)
sleep(2)