-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimpleMenu.ino
121 lines (108 loc) · 2.03 KB
/
SimpleMenu.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
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
#include <DHT22.h>
#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
#include "editObject.h"
const int ConHeight = 2;
const int ConWidth = 16;
int milliseconds = 0;
LiquidCrystal_I2C lcd(0x20,ConWidth, ConHeight);
RTC_DS1307 rtc;
DHT22 myDHT22(9);
editObject godzina(3, 0, 0, 23, &lcd, NULL, NULL);
editObject minuta(6, 0, 0, 59, &lcd, NULL, &godzina);
editObject sekunda(9, 0, 0, 59, &lcd, &godzina, &minuta );
editObject temp(1, 1, 0, 100, &lcd, NULL, NULL);
editObject hum(12, 1, 0, 100, &lcd, NULL, NULL);
byte updown[8] = {
B00100,
B01110,
B11111,
B00000,
B00000,
B11111,
B01110,
B00100
};
byte left[8] = {
B00001,
B00011,
B00111,
B01111,
B00111,
B00011,
B00001
};
byte right[8] = {
B10000,
B11000,
B11100,
B11110,
B11100,
B11000,
B10000
};
byte degree[8] = {
B01110,
B01010,
B01110,
B00000,
B00000,
B00000,
B00000
};
void setup()
{
lcd.init();
lcd.backlight();
Wire.begin();
rtc.begin();
godzina.setLeadingChar(' ');
minuta.setLeadingChar(':');
sekunda.setLeadingChar(':');
temp.setLeadingChar('=');
hum.setLeadingChar('=');
lcd.createChar(0, updown);
lcd.createChar(1, left);
lcd.createChar(2, right);
lcd.createChar(3, degree);
lcd.setCursor(0,0);
sekunda.setReadOnly(false);
sekunda.setActive(false);
}
void loop()
{
delay(100);
DHT22_ERROR_t errorCode;
if (millis()-milliseconds >=2000)
{
if (myDHT22.readData() == DHT_ERROR_NONE)
{
temp.setValue(myDHT22.getTemperatureC());
hum.setValue(myDHT22.getHumidity());
lcd.setCursor(0,1);
lcd.print('T');
temp.print();
lcd.write(byte(3));
lcd.print('C');
lcd.setCursor(11,1);
lcd.print('H');
hum.print();
lcd.print('%');
milliseconds=millis();
}
}
if (rtc.isrunning())
{
DateTime now = rtc.now();
godzina.setValue(now.hour());
minuta.setValue(now.minute());
sekunda.setValue(now.second());
displayTime(&godzina, &minuta, &sekunda);
}
else
{
lcd.setCursor(0,0);
lcd.print("Nie dziala RTC");
}
}