-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlcd_sensor.ino
71 lines (58 loc) · 1.29 KB
/
lcd_sensor.ino
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
Display LCD com sensor de temperatura e Voltagem e um Chave de Estado.
Autor: Jorge Wendell
Email: [email protected]
*/
// include the library code:
#include <LiquidCrystal.h>
#define Luz_Fundo 7
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sensor = A0;
int chave = 8;
byte grau[8] = {
0b01110,
0b01010,
0b01110,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
};
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
pinMode(Luz_Fundo, OUTPUT);
pinMode(chave, INPUT);
digitalWrite(chave, HIGH);
digitalWrite(Luz_Fundo, HIGH);
}
void loop() {
int chaveEstado = digitalRead(chave);
int readsensor = analogRead(sensor);
float voltage = readsensor * 5.0/1023;
float tempC = voltage * 100;
if(chaveEstado == 1){
lcd.setCursor(0, 0);
lcd.print("Voltage V");
lcd.setCursor(0, 1);
lcd.print("Tempo C");
lcd.createChar(1,grau);
lcd.setCursor(12,0);
lcd.print(voltage);
lcd.setCursor(11,1);
lcd.write(1);
lcd.setCursor(12,1);
lcd.print(tempC);
delay(500);
}
if(chaveEstado == 0){
// Print a message to the LCD.
lcd.setCursor(0, 0);
lcd.print("Jorge Wendell QS");
lcd.setCursor(0, 1);
lcd.print(" Arduino LAB! ");
delay(100);
}
}