-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path16*2_lcd.txt
57 lines (51 loc) · 1.14 KB
/
16*2_lcd.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <LiquidCrystal.h>
const int sensorPin = 0;
const int rs=11, en=10;
const int d4=6 , d5=5, d6=4, d7=3;
int val=0;
LiquidCrystal lcd(rs,en, d4, d5, d6,d7);
float volt,tempC,tempF;
void setup()
{
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Temp & Voltage");
lcd.setCursor(0,1);
lcd.print("Meter");
delay(2500);
lcd.clear();
lcd.setCursor(0,0);
Serial.begin(9600);
}
void loop()
{
val = analogRead(sensorPin);
volt = (val) *( 5.0/1024);
tempC = (volt - 0.5) * 100 ;
tempF = (tempC * 9.0 / 5.0) + 32.0;
lcd.setCursor(0,0);
lcd.print("Temp in C : ");
lcd.setCursor(0,1);
lcd.print(tempC);
delay(2500);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temp in F : ");
lcd.setCursor(0,1);
lcd.print(tempF);
delay(2500);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Voltage : ");
lcd.setCursor(0,1);
lcd.print(volt);
delay(2500);
lcd.clear();
delay(100);
Serial.print(tempC);
Serial.println(" degrees C");
Serial.print(tempF);
Serial.println(" degrees F");
Serial.print(volt);
Serial.println(" volts");
}