LCD Temperature Display- Arduino Workshop

LCD Temperature Display

This project will be a simple demonstration of LCD Temperature Display using an LCD to present useful information to the user, in this case, the temperature readout from an analog temperature sensor. We will also add a button to enable the temperature to be displayed in either centigrade or Fahrenheit, whichever you prefer. Also, the maximum and minimum temperatures will be displayed in the second row.

Required Component :

1.Arduino

2. Resistors

3. 6×2 LCD Display Module

4.Potentiometer

5. connecting wire

6. Breadboard

7. Mini Push Button Switch

8. LM35DTAnalog Temp Sensor LM35

Circuit diagram LCD Temperature Display:

I have used an LM35DT temperature sensor, which has a range from 0ºC to 100ºC. You can, of course, use any analog temperature sensor you wish. The LM35 ranges from −55ºC to +150ºC. You will need to adjust your code accordingly

LCD Temperature Display

Code LCD Temperature Display:

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // create an lcd
object and assign the pins
int maxC=0, minC=100, maxF=0, minF=212;
int scale = 1;
int buttonPin=8;
void setup() {
lcd.begin(16, 2); // Set the display
to 16 columns and 2 rows
analogReference(INTERNAL);
// analogReference(INTERNAL1V1); If you have an Arduino Mega
pinMode(buttonPin, INPUT);
lcd.clear();
}
void loop() {
lcd.setCursor(0,0); // set cursor to
home position
int sensor = analogRead(0); // read the temp
from sensor
int buttonState = digitalRead(buttonPin); // check for button
press
switch (buttonState) { // change scale
state if pressed
case HIGH:
scale=-scale; // invert scale
lcd.clear();
}
switch (scale) { // decide if C or F
scale
case 1:
celsius(sensor);
break;
case -1:
fahrenheit(sensor);
}
delay(250);
}
void celsius(int sensor) {
lcd.setCursor(0,0);
int temp = sensor * 0.1074188; // convert to C
lcd.print(temp);
lcd.write(B11011111); // degree symbol
lcd.print("C ");
if (temp>maxC) {maxC=temp;}
if (temp<minC) {minC=temp;}
lcd.setCursor(0,1);
lcd.print("H=");
lcd.print(maxC);
lcd.write(B11011111);
lcd.print("C L=");
lcd.print(minC);
lcd.write(B11011111);
lcd.print("C ");
}
void fahrenheit(int sensor) {
lcd.setCursor(0,0);
float temp = ((sensor * 0.1074188) * 1.8)+32; // convert to F
lcd.print(int(temp));
lcd.write(B11011111); // print degree
symbol
lcd.print("F ");
if (temp>maxF) {maxF=temp;}
if (temp<minF) {minF=temp;}
lcd.setCursor(0,1);
lcd.print("H=");
lcd.print(maxF);
lcd.write(B11011111);
lcd.print("F L=");
lcd.print(minF);
lcd.write(B11011111);
lcd.print("F ");
}

When you run the code, the current temperature will be displayed on the LCD on the top row. The bottom row will display the maximum and minimum temperatures recorded since the Arduino was turned on or the program reset. By pressing the button you can change the temperature scale between
Celsius and Fahrenheit

All Arduino tutorial available Click here

 ALL ARDUINO TUTORIAL 

 186 total views,  1 views today