Parry21
Published

Temperature on an LCD

Check room, body, and outdoor temperatures with an easy to read LCD display.

IntermediateFull instructions provided7,477
Temperature on an LCD

Things used in this project

Story

Read more

Schematics

Temperature Sensor

Assemble, Upload and watch it run!

Code

tmpslcd.ino

C/C++
#include <LiquidCrystal.h>//imports the libraries
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);//sets the LCD pins
const int sensorPin = A0;
float fntemp;
float sum;
float voltage;
int sensorVal;
int count;
void setup() {
  Serial.begin(250000);//begins serial interface
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  sum = 0.0;
  voltage = 0.0;
  fntemp = 0.0;
  sensorVal = 0;
  count = 0;  
}

void loop() {  
  if (count < 30) {//value represents the number of values averaged. Can
    sensorVal = analogRead(sensorPin);//be changed
    voltage = (sensorVal/1024.0)*5.0;//conversion of sensor value to °C
    sum += ((voltage-0.5) * 100);
    count ++;
    delay(1);//needed to recieve different vslues each time
  }
  else {
    fntemp = sum / count;//averaging
    count = 0;
    sum = 0.0;
  }
  Serial.println(fntemp);
  lcd.print(fntemp);
  lcd.print(" C");
  lcd.setCursor(0, 1);
  
  delay(50);//delay to prevent over flashing of the LCD
  lcd.clear();
  delay(0);
}

Credits

Parry21
1 project • 2 followers
Contact

Comments

Please log in or sign up to comment.