![](/media/cache/profiles/3ec0e2c7f4536e7ce9e9ce183b1de9e8.jpg.50x50_q85.jpg)
DS1302 Hello World program
main.cpp
- Committer:
- Gijsvanoort
- Date:
- 2015-02-21
- Revision:
- 1:e747c4ea86e0
- Parent:
- 0:5e6107966aba
File content as of revision 1:e747c4ea86e0:
#define SCLK PTC5 #define IO PTC4 #define CE PTC3 //Comment this line if the DS1302 is already running #define INITIAL_RUN #include "mbed.h" #include "DS1302.h" DS1302 clk(SCLK, IO, CE); int main() { #ifdef INITIAL_RUN clk.set_time(1256729737); #endif char storedByte = clk.recallByte(0); printf("\r\nStored byte was %d, now increasing by one\r\n", storedByte); clk.storeByte(0, storedByte + 1); while(1) { time_t seconds = clk.time(NULL); printf("Time as a basic string = %s\r", ctime(&seconds)); wait(1); } }