#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize the LCD with the correct I2C address and dimensions
LiquidCrystal_I2C lcd(0x27, 16, 2); // Change 0x27 to your LCD's I2C address
#define TEMP_PIN 2 // Single input pin for temperature status
#define FAN_PIN 6 // Output pin for fan control
void setup() {
// Initialize LCD
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
pinMode(TEMP_PIN, INPUT);
pinMode(FAN_PIN, OUTPUT);
// Startup Message
lcd.setCursor(0, 0);
lcd.print("Tempertaure");
lcd.setCursor(0, 1);
lcd.print("Controller");
delay(2000);
lcd.clear();
}
void loop() {
int tempStatus = digitalRead(TEMP_PIN);
if (tempStatus == HIGH) {
lcd.setCursor(0, 0);
lcd.print("Temperature HIGH");
lcd.setCursor(0, 1);
lcd.print("FAN ON ");
digitalWrite(FAN_PIN, HIGH); // Fan ON
}
else if (tempStatus == LOW) {
lcd.setCursor(0, 0);
lcd.print("Temperature LOW ");
lcd.setCursor(0, 1);
lcd.print("FAN OFF ");
digitalWrite(FAN_PIN, LOW); // Fan OFF
}
delay(1000); // Refresh every second
}