i used chatgpt to make the code
C:\Users\jyd\Documents\Arduino\Dht11\Dht11.ino:1:10: fatal error: dht.h: No such file or directory
#include <dht.h>
^~~~~~~
compilation terminated.
exit status 1
Compilation error: dht.h: No such file or directory
#include <dht.h>
// Define DHT sensor type and pin
#define DHTPIN 2
#define DHTTYPE DHT11 // Use DHT22 if you have one
DHT dht(DHTPIN, DHTTYPE);
// Define RGB LED pins
#define RED_PIN 9
#define GREEN_PIN 10
#define BLUE_PIN 11
void setup() {
Serial.begin(9600);
dht.begin();
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
Serial.println("Temperature & Humidity RGB Indicator");
}
void loop() {
// Read temperature and humidity
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
// Check if the readings are valid
if (isnan(temperature) || isnan(humidity)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print(" °C, Humidity: ");
Serial.print(humidity);
Serial.println(" %");
// Determine LED color based on temperature
if (temperature < 20) {
setColor(0, 0, 255); // Blue for cool temperatures
} else if (temperature >= 20 && temperature <= 30) {
setColor(0, 255, 0); // Green for comfortable temperatures
} else {
setColor(255, 0, 0); // Red for high temperatures
}
delay(2000); // Wait 2 seconds before next reading
}
// Function to set RGB LED color
void setColor(int red, int green, int blue) {
analogWrite(RED_PIN, red);
analogWrite(GREEN_PIN, green);
analogWrite(BLUE_PIN, blue);
}