16 x 2 LCD and Analog Temp Sensor on Arduino

This project uses a 16 x 2 LCD Display to show the temperature in Fahrenheit and Celsius using an analog temperature sensor.

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);

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.setCursor(0, 0);
  lcd.print("Temp in F:");
  lcd.setCursor(11, 0);
  lcd.print(temperatureF);

  lcd.setCursor(0, 1);
  lcd.print("Temp in C:");
  lcd.setCursor(11, 1);
  lcd.print(temperatureC);

  delay(2000);
  }

Be the first to comment

Leave a Reply