1#include "LedControl.h"
2
3
11LedControl lc=LedControl(12,10,11,1);
12const
13 int seth = 4;
14const int setm = 3;
15const int setc = 2;
16
17int second ;
18
19 int minute ;
20int hour ;
21
22int correction = 0;
23
24
25unsigned long previousMillis
26 = 0;
27const long interval = 1000;
28
29
30void setup() {
31 lc.shutdown(0,false);
32
33 lc.setIntensity(0,12);
34 lc.clearDisplay(0);
35}
36void loop() {
37 if
38 (digitalRead(seth)== HIGH){
39 hour++;
40 delay(200);
41 if(hour>23){
42
43 hour=00;
44 }
45 }
46 if (digitalRead(setm)== HIGH){
47 minute++;
48
49 delay(200);
50 if(minute>59){
51 minute=00;
52 }
53 }
54 if (digitalRead(setc)==
55 HIGH){
56 correction++;
57 delay(200);
58 if(correction>59){
59 correction=00;
60
61 }
62 }
63 unsigned long currentMillis = millis();
64 if (currentMillis -
65 previousMillis >= interval) {
66 previousMillis = currentMillis;
67 second++;
68
69 if(second>59)
70 {
71 minute++;
72 second=00;
73 }
74 if(minute>59)
75
76 {
77 hour++;
78 minute=00;
79 second = second + correction;
80 }
81 if(hour>23)
82 { hour=00; minute=00; second=correction; }
83 }
84
85lc.setDigit(0,1,hour % 10,true);
86lc.setDigit(0,0,(hour
87 - hour % 10) / 10,false);
88lc.setDigit(0,3,minute % 10,false);
89lc.setDigit(0,2,(minute
90 - minute % 10) / 10,false);
91lc.setDigit(0,5,second % 10,true);
92lc.setDigit(0,4,(second
93 - second % 10) / 10,false);
94lc.setDigit(0,7,correction % 10,false);
95lc.setDigit(0,6,(correction
96 - correction % 10) / 10,false);
97}
98