-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78b5ebf
commit b95a459
Showing
2 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* Copyright (c) 2016 Edward Yang | ||
* All rights reserved. | ||
* | ||
*/ | ||
|
||
#include "DS3231.h" | ||
|
||
/* | ||
* Example program for Arduino | ||
*/ | ||
|
||
void setup() { | ||
Wire.begin(); | ||
Serial.begin(9600); | ||
// Set the initial time | ||
ts t; | ||
t.sec = 0; | ||
t.min = 0; | ||
t.hour = 0; | ||
t.dayOfWeek = 4; | ||
t.day = 25; | ||
t.month = 5; | ||
t.year = 16; | ||
set(t); | ||
} | ||
|
||
void print(ts t) { | ||
Serial.print("20"); | ||
Serial.print(t.year, DEC); | ||
Serial.print("/"); | ||
Serial.print(t.month, DEC); | ||
Serial.print("/"); | ||
Serial.print(t.day, DEC); | ||
Serial.print(" "); | ||
|
||
if (t.hour < 10) { | ||
Serial.print("0"); | ||
} | ||
Serial.print(t.hour, DEC); | ||
Serial.print(":"); | ||
if (t.min < 10) { | ||
Serial.print("0"); | ||
} | ||
Serial.print(t.min, DEC); | ||
Serial.print(":"); | ||
if (t.sec < 10) { | ||
Serial.print("0"); | ||
} | ||
Serial.print(t.sec, DEC); | ||
Serial.print("\n"); | ||
} | ||
|
||
void loop() { | ||
ts t; | ||
get(&t); | ||
print(t); | ||
delay(1000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters