arduino:ds1302
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| arduino:ds1302 [2017/07/23 09:48] – aistis | arduino:ds1302 [2017/07/23 09:58] (current) – aistis | ||
|---|---|---|---|
| Line 16: | Line 16: | ||
| ir veikia: | ir veikia: | ||
| - | {{: | + | {{: |
| + | |||
| + | kodas: | ||
| + | |||
| + | <code c> | ||
| + | // DS1302_Serial_Easy (C)2010 Henning Karlsen | ||
| + | // web: http:// | ||
| + | // | ||
| + | // A quick demo of how to use my DS1302-library to | ||
| + | // quickly send time and date information over a serial link | ||
| + | // | ||
| + | // I assume you know how to connect the DS1302. | ||
| + | // DS1302: | ||
| + | // I/O pin -> Arduino Digital 3 | ||
| + | // SCLK pin -> Arduino Digital 4 | ||
| + | |||
| + | #include < | ||
| + | |||
| + | // Init the DS1302 | ||
| + | DS1302 rtc(8, 7, 6); | ||
| + | |||
| + | void setup() | ||
| + | { | ||
| + | // Set the clock to run-mode, and disable the write protection | ||
| + | rtc.halt(false); | ||
| + | rtc.writeProtect(false); | ||
| + | |||
| + | // Setup Serial connection | ||
| + | Serial.begin(9600); | ||
| + | |||
| + | // rtc.setDOW(SUNDAY); | ||
| + | // rtc.setTime(9, | ||
| + | // rtc.setDate(23, | ||
| + | } | ||
| + | |||
| + | void loop() | ||
| + | { | ||
| + | // Send Day-of-Week | ||
| + | Serial.print(rtc.getDOWStr()); | ||
| + | Serial.print(" | ||
| + | |||
| + | // Send date | ||
| + | Serial.print(rtc.getDateStr()); | ||
| + | Serial.print(" | ||
| + | |||
| + | // Send time | ||
| + | Serial.println(rtc.getTimeStr()); | ||
| + | |||
| + | // Wait one second before repeating :) | ||
| + | delay (1000); | ||
| + | } | ||
| + | </ | ||
| + | |||
arduino/ds1302.1500792521.txt.gz · Last modified: by aistis
