Skip to content

Instantly share code, notes, and snippets.

/.ino

Created September 16, 2016 02:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/2071109e2be67f780608d7cea8805ddb to your computer and use it in GitHub Desktop.
#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