from machine import Pin, ADC, PWM
from time import sleep
import dht
sensor_hum = dht.DHT22(Pin(2))
servomotor = PWM(15)
servomotor.freq(50)
while True:
sensor_hum.measure()
temp = sensor_hum.temperature()
hum = sensor_hum.humidity()
servomotor.duty_u16(int(2*(65535 / 100)))
if temp >= 30:
print('Temperatura:', '{:.1f} C'.format(temp))
print('Humedad:', '{:.1f}%'.format(hum))
servomotor.duty_u16(int(7*(65535 / 100)))
servomotor.duty_u16(int(2*(65535 / 100)))
sleep(1)