-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharduino
More file actions
68 lines (61 loc) · 1.92 KB
/
Copy patharduino
File metadata and controls
68 lines (61 loc) · 1.92 KB
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
#include <iarduino_RTC.h> // / iarduino_RTC for working with real-time modules
iarduino_RTC time(RTC_DS1302, 8, 6, 7); // The time object for the module DS1302, to the conclusions of RST, CLK, DAT
int IN4 = 5;
int IN3 = 4;
int IN2 = 3;
int IN1 = 2;
//int H; // hours in 24-hour format from 0 to 23
int i; // minutes from 0 to 59
//int y; // year without century from 0 to 99
//int on = 2; // on 24-hour format from 0 to 23
int off = 3; // off in 24-hour format from 0 to 23
void setup(){
delay(300);
time.begin();
Serial.begin(9600);
pinMode (IN4, OUTPUT);
pinMode (IN3, OUTPUT);
pinMode (IN2, OUTPUT);
pinMode (IN1, OUTPUT);
//time.settime(0,20,10,7,2,19); // enable debugging
if (time.year == 1) { // if the clock is reset
Serial.setTimeout(1000); // input timeout
//Serial.println("hours: 12"); H = Serial.parseInt();
Serial.println("minutes: 1"); i = Serial.parseInt();
//Serial.println("year: 19"); y = Serial.parseInt();
time.settime(1);
}
else
Serial.print("Time and year = "); Serial.println(time.gettime("H:i Y"));
time.period(i);
Serial.end();
}
void loop() {
if(millis()%60000==0){ // if 1 second has passed
Serial.println(time.gettime("d-m-Y, H:i:s, D")); // display time
delay(1); // suspend for 1 ms, so as not to display time several times in 1ms
digitalWrite (IN1, HIGH);
digitalWrite (IN2, HIGH);
digitalWrite (IN3, LOW);
digitalWrite (IN4, LOW);
delay(1);
delay(002000);
digitalWrite (IN1, LOW);
digitalWrite (IN2, LOW);
digitalWrite (IN3, LOW);
digitalWrite (IN4, LOW);
delay(1);
delay(i);
digitalWrite (IN1, LOW);
digitalWrite (IN2, LOW);
digitalWrite (IN3, HIGH);
digitalWrite (IN4, HIGH);
delay(1);
delay(002000);
digitalWrite (IN1, LOW);
digitalWrite (IN2, LOW);
digitalWrite (IN3, LOW);
digitalWrite (IN4, LOW);
delay(1);
delay(i);
}