-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEMP_LCD.ino
64 lines (51 loc) · 1.1 KB
/
TEMP_LCD.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
/*
Autor: Edgard José Díaz Tipacamú
Date: Oct 2019
This code reads the temperature and humidity sensor DCH 11.
In addition, the configuration of an LCD screen is carried out in
which the data obtained from the above-mentioned sensor are shown.
*/
#include<LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs,en, d4,d5,d6,d7);
#include "DHT.h"
#define DHTPIN 8
#define DHTTYPE DHT11
DHT Sensor(DHTPIN,DHTTYPE);
#define led 9
void setup()
{
lcd.begin(16,2);
pinMode(led,OUTPUT);
}
void loop()
{
while(1)
{
float h, t;
h = Sensor.readHumidity();
t = Sensor.readTemperature();
temperatura(t);
humedad(h);
delay(2000);
digitalWrite(led,HIGH);
delay(100);
digitalWrite(led,LOW);
}
}
float temperatura(float temp)
{
lcd.setCursor(0,1);
lcd.print("Temp: ");
lcd.print(temp);
lcd.print(" c");
return 0;
}
float humedad(float Humedad)
{
lcd.setCursor(0,0);
lcd.print("Humedad: ");
lcd.print(Humedad);
lcd.print("%");
return 0;
}