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:
- Arduino Uno – https://store.arduino.cc/usa/arduino-uno-rev3
- LCD Screen – https://www.adafruit.com/product/1447
- Analog Temperature Sensor – https://amzn.to/2Rkkl3k
- Potentiometer (50K) – https://amzn.to/2N1NH8h
- 220 Ohm Resistors – https://amzn.to/2RiiMD9
- Breadboard Kit – https://amzn.to/2Xih5ei
#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