LCD Temperature Alert System with Arduino

This project allows you to build a temperature alert system that will not just tell end users that there is an issue, but what they should do about it.

Functional Parts in the Project:

#include <LiquidCrystal.h>

#define sensorPin  A0

#define rs 12
#define en 11
#define d4 5
#define d5 4
#define d6 3
#define d7 2

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

int plusMinus;

void setup() {
  lcd.begin(16, 2);
}

void loop() {
  int reading = analogRead(sensorPin);
  float voltage = reading * 5.0;
  voltage /= 1024.0;
  float temperatureC = (voltage - 0.5) * 100 ;
  float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;

  lcd.clear();

  if (temperatureF >= 80) {
    plusMinus = temperatureF - 75;

    lcd.setCursor(0, 0);
    lcd.print("WARNING");

    lcd.setCursor(0, 1);
    lcd.print("Temp:");
    lcd.setCursor(6, 1);
    lcd.print(temperatureF);
    lcd.setCursor(12, 1);
    lcd.print("+");
    lcd.setCursor(13, 1);
    lcd.print(plusMinus);

    
    delay(2000);
    lcd.clear();

    lcd.setCursor(0, 0);
    lcd.print("CALL - BOB ROSS");

    lcd.setCursor(0, 1);
    lcd.print("111-222-3333");
    delay(2000);
  }

  else if (temperatureF < 80 && temperatureF >= 75) {
    plusMinus = temperatureF - 75;

    lcd.setCursor(0, 0);
    lcd.print("ALERT");

    lcd.setCursor(0, 1);
    lcd.print("Temp:");
    lcd.setCursor(6, 1);
    lcd.print(temperatureF);
    lcd.setCursor(12, 1);
    lcd.print("+");
    lcd.setCursor(13, 1);
    lcd.print(plusMinus);

    }

  else {
    plusMinus =  75 - temperatureF;

    lcd.setCursor(0, 0);
    lcd.print("GOOD");

    lcd.setCursor(0, 1);
    lcd.print("Temp:");
    lcd.setCursor(6, 1);
    lcd.print(temperatureF);
    lcd.setCursor(12, 1);
    lcd.print("-");
    lcd.setCursor(13, 1);
    lcd.print(plusMinus);
  }

  delay(2000);
}

Be the first to comment

Leave a Reply