Display RTC on LCD. User is also able to update RTC from console.

Dependencies:   TextLCD mbed

Committer:
bcostm
Date:
Fri Feb 21 10:00:46 2014 +0000
Revision:
0:bad75bd13618
Child:
1:1b17dcd80a7d
Initial version.

Who changed what in which revision?

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