-
Notifications
You must be signed in to change notification settings - Fork 0
/
reloj.ino
73 lines (65 loc) · 1.35 KB
/
reloj.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
void funcionReloj() {
unsigned long temp1 = millis();
if (temp1 - preTemp1 > unSegundo) {
preTemp1 = temp1;
digitalClockDisplayDebug();
Serial.print(luz);
PintarReloj();
}
BTN_FUN.read();
if (BTN_FUN.wasPressed()) {
estadoActual = M_ALARMA;
}
}
void PintarReloj() {
// digital clock display of the time
pantalla.setCursor(0, 0);
dosDigitosLCD(hour());
pantalla.print(":");
dosDigitosLCD(minute());
pantalla.print(":");
dosDigitosLCD(second());
pantalla.print(" ");
pantalla.print(temperaturaC);
pantalla.write(byte(0));
pantalla.setCursor(0, 1);
dosDigitosLCD(day());
pantalla.print("/");
dosDigitosLCD(month());
pantalla.print("/");
pantalla.print(year());
pantalla.setCursor(15, 1);
if (alarmaON) {
pantalla.write(byte(2));
}
else {
pantalla.write(byte(1));
}
}
void digitalClockDisplayDebug() {
// digital clock display of the time
dosDigitos(hour());
Serial.print(":");
dosDigitos(minute());
Serial.print(":");
dosDigitos(second());
Serial.print(" ");
Serial.print(day());
Serial.print("/");
Serial.print(month());
Serial.print("/");
Serial.print(year());
Serial.println();
}
void dosDigitos(int n) {
if (n < 10) {
Serial.print("0");
}
Serial.print(n);
}
void dosDigitosLCD(int n) {
if (n < 10) {
pantalla.print("0");
}
pantalla.print(n);
}