const int relay1Pin = 8;
const int relay2Pin = 4;
const int ldrPin = A0;
const int ntcPin = A1;
const int lcdRS = 12;
const int lcdEN = 11;
const int lcdD4 = 5;
const int lcdD5 = 4;
const int lcdD6 = 3;
const int lcdD7 = 2;
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
pinMode(relay1Pin, OUTPUT);
pinMode(relay2Pin, OUTPUT);
pinMode(ldrPin, INPUT);
pinMode(ntcPin, INPUT);
lcd.init();
lcd.backlight();
}
void loop() {
int ldrValue = analogRead(ldrPin);
int ntcValue = analogRead(ntcPin);
float temperature = (ntcValue * 5.0 / 1023.0 - 0.5) * 100.0;
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print(" C");
if (ldrValue < 400) {
digitalWrite(relay1Pin, HIGH);
digitalWrite(relay2Pin, LOW);
} else {
digitalWrite(relay1Pin, LOW);
digitalWrite(relay2Pin, HIGH);
}
delay(500);
}