#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
const int fanMotorPin = 13;
const int sulamaMotorPin = 8;
const int thresholdTemp = 23;
const int thresholdHum = 39;
void setup() {
Serial.begin(9600);
dht.begin();
pinMode(fanMotorPin, OUTPUT);
pinMode(sulamaMotorPin, OUTPUT);
}
void loop() {
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
Serial.print("Sicaklik: ");
Serial.print(temperature);
Serial.print(" °C - Nem: ");
Serial.print(humidity);
Serial.println();
// Sıcaklık eşik değerini kontrol edelim
if (temperature > thresholdTemp) {
// Motoru çalıştıralım
digitalWrite(fanMotorPin, HIGH);
} else {
// Motoru durduralım
digitalWrite(fanMotorPin, LOW);
}
// Nem eşik değerini kontrol edelim
if (humidity < thresholdHum) {
// Motoru çalıştıralım
digitalWrite(sulamaMotorPin, HIGH);
} else {
// Motoru durduralım
digitalWrite(sulamaMotorPin, LOW);
}
delay(2000);
}