Program to test RTC functionality

Dependencies:   mbed-dev

Committer:
michaelVisimid
Date:
Tue Jan 31 21:35:13 2017 +0000
Revision:
0:a13634459c68
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
michaelVisimid 0:a13634459c68 1 #include "mbed.h"
michaelVisimid 0:a13634459c68 2
michaelVisimid 0:a13634459c68 3 DigitalOut myled(LED1);
michaelVisimid 0:a13634459c68 4
michaelVisimid 0:a13634459c68 5 int main() {
michaelVisimid 0:a13634459c68 6
michaelVisimid 0:a13634459c68 7 printf("RTC example\n");
michaelVisimid 0:a13634459c68 8 set_time(1387188323); // Set RTC time to 16 December 2013 10:05:23 UTC
michaelVisimid 0:a13634459c68 9 printf("Date and time are set.\n");
michaelVisimid 0:a13634459c68 10
michaelVisimid 0:a13634459c68 11 while(1) {
michaelVisimid 0:a13634459c68 12
michaelVisimid 0:a13634459c68 13 time_t seconds = time(NULL);
michaelVisimid 0:a13634459c68 14
michaelVisimid 0:a13634459c68 15 //printf("Time as seconds since January 1, 1970 = %d\n", seconds);
michaelVisimid 0:a13634459c68 16
michaelVisimid 0:a13634459c68 17 printf("Time as a basic string = %s", ctime(&seconds));
michaelVisimid 0:a13634459c68 18
michaelVisimid 0:a13634459c68 19 //char buffer[32];
michaelVisimid 0:a13634459c68 20 //strftime(buffer, 32, "%I:%M:%S %p\n", localtime(&seconds));
michaelVisimid 0:a13634459c68 21 //printf("Time as a custom formatted string = %s", buffer);
michaelVisimid 0:a13634459c68 22
michaelVisimid 0:a13634459c68 23 myled = !myled;
michaelVisimid 0:a13634459c68 24 wait(1);
michaelVisimid 0:a13634459c68 25 }
michaelVisimid 0:a13634459c68 26 }