🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X
Questions
























Write an Arduino program to interface a temperature monitoring system in a public environment which will display information on 16*2 LCD. The display should show "Fever" if temp. is greater than 99.6 degrees and "No fever" if the temp.is below 99.6 degrees. (Use of DHT11 or LM35 temperature sensor is permissible).

Last Updated : 15 Jul 2025 Jan 24, Jul 24

Solution:

#include <LiquidCrystal.h>
const int lm35 = A2;      // LM35 sensor pin
const int rs = 11;       // RS pin for LCD
const int en = 10;       // EN pin for LCD
const int d4 = 9;        // Data pin 4 for LCD
const int d5 = 8;        // Data pin 5 for LCD
const int d6 = 7;        // Data pin 6 for LCD
const int d7 = 6;        // Data pin 7 for LCD

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

void setup(){
    lcd.begin(16, 2);      // Set up LCD with 16x2 display
    lcd.print("Checking..."); // Initial message
}

void loop(){
    int adcvalue = analogRead(lm35);          // Read LM35 value
    float tempVoltage = adcvalue * 4.88;      // Convert to voltage
    float tempval = tempVoltage / 10;         // Convert to temperature

    lcd.clear();                             // Clear display
    if (tempval > 99.6) {
        lcd.print("Fever");                  // Display "Fever"
    } else {
        lcd.print("No Fever");               // Display "No Fever"
    }

    delay(2000);                             // Wait 2 seconds
}

OUTPUT DESCRIPTION:

This code reads the temperature from an LM35 sensor, converts it to Celsius, 
and displays "Fever" or "No Fever" on a 16x2 LCD based on whether the
 temperature exceeds 99.6°C. The display is updated every 2 seconds.

Code Explaintion:
Library and Pin Definitions:

    • #include <LiquidCrystal.h>: Includes the library for controlling the LCD.
    • const int lm35 = A2;: Defines the analog pin for the LM35 temperature sensor.
    • const int rs = 11;: Defines the pin for the LCD Register Select.
    • const int en = 10;: Defines the pin for the LCD Enable.
    • const int d4 = 9;: Defines the pin for LCD Data 4.
    • const int d5 = 8;: Defines the pin for LCD Data 5.
    • const int d6 = 7;: Defines the pin for LCD Data 6.
    • const int d7 = 6;: Defines the pin for LCD Data 7.
  • Setup Function (setup):

    • lcd.begin(16, 2);: Initializes the LCD with a 16x2 display.
    • lcd.print("Checking...");: Displays the initial message "Checking..." on the LCD.
  • Main Loop (loop):

    • int adcvalue = analogRead(lm35);: Reads the value from the LM35 sensor.
    • float tempVoltage = adcvalue * 4.88;: Converts the ADC value to voltage.
    • float tempval = tempVoltage / 10;: Converts the voltage to temperature in Celsius.
  • Display Update:

    • lcd.clear();: Clears the LCD screen.
    • if (tempval > 99.6): Checks if the temperature is above 99.6°C.
      • lcd.print("Fever");: Displays "Fever" if the temperature is high.
    • else:
      • lcd.print("No Fever");: Displays "No Fever" if the temperature is normal.
  • Delay:

    • delay(2000);: Waits for 2 seconds before updating the display again.

 

Report an error

Meanwhile you can watch this video

Watch Video
Latest Updates