Skip to content

Commit ffb03a6

Browse files
committed
Bugfixes and Clean up
1 parent e2fc67c commit ffb03a6

File tree

15 files changed

+489
-481
lines changed

15 files changed

+489
-481
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
2+
#include <Wire.h>
3+
#include <I2C_RTC.h>
4+
5+
//static DS1307 RTC;
6+
//static DS3231 RTC;
7+
//static PCF8523 RTC;
8+
//static PCF8563 RTC;
9+
10+
int hours,minutes,seconds,day,month,year;
11+
12+
void setup()
13+
{
14+
Serial.begin(9600);
15+
while (!Serial); // wait for serial port to connect. Needed for native USB
16+
17+
RTC.begin();
18+
19+
Serial.print("Is Clock Running: ");
20+
if (RTC.isRunning())
21+
{
22+
Serial.println("Yes");
23+
switch (RTC.getWeek())
24+
{
25+
case 1: Serial.print("MON");
26+
break;
27+
case 2: Serial.print("TUE");
28+
break;
29+
case 3: Serial.print("WED");
30+
break;
31+
case 4: Serial.print("THU");
32+
break;
33+
case 5: Serial.print("FRI");
34+
break;
35+
case 6: Serial.print("SAT");
36+
break;
37+
case 7: Serial.print("SUN");
38+
break;
39+
}
40+
Serial.print(" ");
41+
42+
day=RTC.getDay();
43+
month=RTC.getMonth();
44+
year=RTC.getYear();
45+
46+
if(day<10)
47+
Serial.print("0");
48+
49+
Serial.print(RTC.getDay());
50+
Serial.print("-");
51+
if(month<10)
52+
Serial.print("0");
53+
Serial.print(RTC.getMonth());
54+
Serial.print("-");
55+
Serial.print(RTC.getYear());
56+
Serial.print(" ");
57+
58+
hours = RTC.getHours();
59+
minutes = RTC.getMinutes();
60+
seconds = RTC.getSeconds();
61+
62+
if(hours<10)
63+
Serial.print("0");
64+
Serial.print(hours);
65+
Serial.print(":");
66+
if(minutes<10)
67+
Serial.print("0");
68+
Serial.print(minutes);
69+
Serial.print(":");
70+
if(seconds<10)
71+
Serial.print("0");
72+
Serial.print(RTC.getSeconds());
73+
Serial.print("");
74+
if (RTC.getHourMode() == CLOCK_H12)
75+
{
76+
switch (RTC.getMeridiem())
77+
{
78+
case HOUR_AM:
79+
Serial.print(" AM");
80+
break;
81+
case HOUR_PM:
82+
Serial.print(" PM");
83+
break;
84+
}
85+
}
86+
Serial.println();
87+
delay(1000);
88+
}
89+
else
90+
{
91+
delay(250);
92+
93+
Serial.println("No");
94+
Serial.println("Setting Time");
95+
RTC.setHourMode(CLOCK_H12); //Comment if RTC PCF8563
96+
//RTC.setHourMode(CLOCK_H24);
97+
RTC.setDateTime(__DATE__, __TIME__);
98+
RTC.updateWeek(); //Update Weekdaybased on new date.
99+
Serial.println("New Time Set");
100+
Serial.print(__DATE__);
101+
Serial.print(" ");
102+
Serial.println(__TIME__);
103+
RTC.startClock(); //Start the Clock;
104+
}
105+
}
106+
107+
void loop()
108+
{
109+
}

examples/DS1307/DS1307_Auto/DS1307_Auto.ino

Lines changed: 0 additions & 62 deletions
This file was deleted.

examples/DS1307/DS1307_Info/DS1307_Info.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ static DS1307 RTC;
66
void setup()
77
{
88
Serial.begin(9600);
9+
while (!Serial) {
10+
; // wait for serial port to connect. Needed for native USB
11+
}
912
RTC.begin();
1013

1114
Serial.println();
@@ -32,7 +35,6 @@ void setup()
3235
else
3336
Serial.println("No");
3437

35-
3638
}
3739

3840
void loop()

examples/DS3231/DS3231_Auto/DS3231_Auto.ino

Lines changed: 0 additions & 64 deletions
This file was deleted.

examples/PCF8523/PCF8523_Auto/PCF8523_Auto.ino

Lines changed: 0 additions & 64 deletions
This file was deleted.

examples/PCF8523/PCF8523_Info/PCF8523_Info.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ static PCF8523 RTC;
66
void setup()
77
{
88
Serial.begin(9600);
9+
while (!Serial) {
10+
; // wait for serial port to connect. Needed for native USB
11+
}
912
RTC.begin();
1013

1114
Serial.println();

examples/PCF8563/PCF8563_Auto/PCF8563_Auto.ino

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)