#include #include // Include the LCD library for I2C LiquidCrystal_I2C lcd(0x27, 16, 2); // LCD I2C address (0x27) and size (16x2) const int sensorPin = A0; // TMP36 sensor connected to analog pin A0 const int greenLED = 5; // Green LED connected to pin 5 const int redLED = 6; // Red LED connected to pin 6 const int buzzer = 4; // Buzzer connected to pin 9 // Temperature threshold const float baselineTemp = 40.0; // Set the baseline temperature (e.g., 30°C) void setup() { // Initialize pins pinMode(greenLED, OUTPUT); pinMode(redLED, OUTPUT); pinMode(buzzer, OUTPUT); // Initialize the LCD lcd.init(); // Start the LCD with 16 columns and 2 rows lcd.backlight(); // Make sure backlight is off initially // Initialize Serial Monitor for debugging Serial.begin(9600); lcd.clear(); lcd.print("TempCheck"); delay(1500); lcd.clear(); } void loop() { // Read TMP36 sensor value int sensorValue = analogRead(sensorPin); // Read the sensor value (0-1023) float voltage = sensorValue * (5.0 / 1023.0); // Convert sensor value to voltage (0-5V) float celsius = (voltage - 0.5) * 100.0; // Convert voltage to temperature (TMP36 formula) // Display temperature on the Serial Monitor Serial.print("Temp: "); Serial.print(celsius); Serial.println(" C"); // Display temperature on the LCD lcd.clear(); lcd.print("Temp: "); lcd.print(celsius); lcd.print(" C"); // Status check for temperature threshold if (celsius > baselineTemp) { digitalWrite(greenLED, LOW); // Turn off green LED digitalWrite(redLED, HIGH); // Turn on red LED //digitalWrite(buzzer, HIGH); // Turn on buzzer tone(buzzer, 440); lcd.clear(); lcd.print("Status: HOT!"); } else { digitalWrite(greenLED, HIGH); // Turn on green LEDnoTone digitalWrite(redLED, LOW); // Turn off red LED //digitalWrite(buzzer, LOW); // Turn off buzzer noTone(buzzer); lcd.clear(); lcd.print("Status: Normal"); } delay(1000); // Wait for 1 second before updating the reading }