This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <FastLED.h> | |
#include <DHT.h> | |
DHT dht(8, DHT11); | |
void setup() { | |
Serial.begin(115200); | |
Serial.println("DHT11 test!"); | |
FastLED.addLeds<WS2812B, 9, GRB>(NULL, 2); | |
dht.begin(); | |
} | |
void loop() { | |
float t = dht.readTemperature(); | |
if (isnan(t)) { | |
Serial.println("Failed to read from DHT sensor!"); | |
} else { | |
t = constrain(t, 10, 30); | |
uint8_t hue = -0.0925*t*t*t + 5.4802*t*t - 106.94*t + 773.93; | |
FastLED.showColor(CHSV(hue, 255, 255)); | |
Serial.print("Temperature: "); | |
Serial.print(t); | |
Serial.print(" °C\t"); | |
Serial.print("Hue: "); | |
Serial.print(hue); | |
Serial.println(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment