#include <Adafruit_NeoPixel.h> // Include the Adafruit NeoPixel library
#include "DHT.h"
#define DHTPIN 26
#define DHTTYPE DHT22
#define LED_PIN 14 // NeoPixel LED strip
#define NUM_LEDS 16 // Number of LEDs
// Create an instance of the Adafruit_NeoPixel class
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
Serial.printf ("DHTxx test!\n");
dht.begin();
strip.begin(); // Initialize the NeoPixel strip
strip.show(); // Set initial color to black
}
void loop() {
for (int i = 0; i < NUM_LEDS; i++) {
strip.setPixelColor(i, 0, 0, 0);
strip.show();
}
delay(100);
float luftfeuchte = dht.readHumidity();
float temperatur = dht.readTemperature();
Serial.printf("Luftfeuchte: %f, Temperatur: %f \n",luftfeuchte,temperatur );
if(temperatur > 30) {
for (int i = 0; i < NUM_LEDS; i++) {
strip.setPixelColor(i, 255, 0, 0);
strip.show();
delay(100);
}
for (int i = 0; i < NUM_LEDS; i++) {
strip.setPixelColor(i, 0, 0, 0); // Set the color of the i-th LED to black (turn it off)
strip.show(); // Update the LED strip with the new colors
}
} else {
for (int i = 0; i < NUM_LEDS; i++) {
strip.setPixelColor(i, 0, 255, 0);
strip.show();
delay(100);
}
delay(1000);
}
}