Simple program to access time from mbed's internal RTC Battery needs to be connected to specified pins on manual
Revision 0:3bcda94a334a, committed 2014-01-08
- Comitter:
- kuldipmaharjan
- Date:
- Wed Jan 08 00:54:40 2014 +0000
- Commit message:
- Simple program to access time from mbed's internal RTC; Battery needs to be connected to specified pins on manual
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jan 08 00:54:40 2014 +0000 @@ -0,0 +1,27 @@ +//Author: Kuldip Maharjan +//Email : kuldipmaharjan@gmail.com +//Anyone can use this code if it helps in their projects or +//for learning programing in mbed besides for commercial purposes + +//Simple program to access time from mbed's internal RTC +//Battery needs to be connected to specified pins on manual + +#include "mbed.h" + +Serial pc(p9, p10); // tx, rx +int main() +{ + pc.baud(115200); + set_time(1361223433); // http://www.epochconverter.com/ + + while (true) { + time_t seconds = time(NULL); + pc.printf("Time as a basic string = %s \n", ctime(&seconds)); + + //char buffer[32]; + // strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); + //pc.printf("Time as a custom formatted string = %s", buffer); + + wait(1); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jan 08 00:54:40 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/0883845fe643 \ No newline at end of file