#include #include dht DHT; Timer timer; #define DHT_PIN 2 #define PWM_PIN 3 void setup() { timer.every(1000, updatePWM); } void loop() { timer.update(); } void updatePWM() { int chk = DHT.read22(DHT_PIN); if(chk == DHTLIB_OK) { byte pwm = map(constrain(DHT.humidity, 60, 100), 60, 100, 0, 255); analogWrite(PWM_PIN, pwm); } else { analogWrite(PWM_PIN, 255); } }