sensor de temperatura con lcd y led
Publicado por Guillermo (2 intervenciones) el 09/08/2020 20:21:25
Hola buenas tardes me podrian ayudar con un codigo voy iniciando, lo que quiero es que me prendan los led con la baja y subida de temperatura ya lo imprime en la pantalla lcd solo falta los led
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include <LiquidCrystal.h>
int sensor = A5;
int temp = 0;
int tempF = 0;
int tempK = 0;
int val = 0;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
byte UNO[8] = {
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
};
byte DOS[8] = {
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
};
byte TRES[8] = {
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
};
byte CUATRO[8] = {
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
};
byte CINCO[8] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
};
byte simGrad[8] = {
B00110,
B01001,
B01001,
B00110,
B00000,
B00000,
B00000,
B00000,
};
void setup() {
lcd.createChar(0, UNO);
lcd.createChar(1, DOS);
lcd.createChar(2, TRES);
lcd.createChar(3, CUATRO);
lcd.createChar(4, CINCO);
lcd.createChar(5, simGrad);
lcd.begin(16, 2);
lcd.setCursor(4,0);
lcd.print("CARGANDO");
for(int i = 0; i <= 15; i++){
lcd.setCursor(i, 1);
lcd.write(byte(0));
delay(50);
lcd.setCursor(i, 1);
lcd.write(byte(1));
delay(50);
lcd.setCursor(i, 1);
lcd.write(byte(2));
delay(50);
lcd.setCursor(i, 1);
lcd.write(byte(3));
delay(50);
lcd.setCursor(i, 1);
lcd.write(byte(4));
delay(50);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
Serial.begin(9600);
}
lcd.clear();
}
void loop() {
temp = (5 * analogRead(sensor) * 100) / 1024;
tempF = (temp*1.85)+32;
tempK = temp + 273;
lcd.setCursor(0,0);
lcd.print("T");
lcd.write(byte(5));
lcd.print("C=");
lcd.print(temp);
lcd.setCursor(0,1);
lcd.print("T");
lcd.write(byte(5));
lcd.print("F=");
lcd.print(tempF);
lcd.setCursor(8,0);
lcd.print("T");
lcd.print("K=");
lcd.print(tempK);
delay(300);
lcd.clear();
val = analogRead(1);
float av =(val/1024.0)=5000;
float temp= av/10;
Serial.print("temperatura");
Serial.println(temp);
delay(100);
if(temp>30){
digitalWrite(12, HIGH);
}
else{
digitalWrite(12, LOW);
}
if(temp>100){
digitalWrite(11, HIGH);
}
else{
digitalWrite(11, LOW);
}
if(temp>120){
digitalWrite(10, HIGH);
}
else{
digitalWrite(10, LOW);
}
}
Valora esta pregunta


0