Program to test RTC functionality

Dependencies:   mbed-dev

Files at this revision

API Documentation at this revision

Comitter:
michaelVisimid
Date:
Tue Jan 31 21:35:13 2017 +0000
Commit message:
Initial commit

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-dev.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r a13634459c68 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jan 31 21:35:13 2017 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+
+int main() {
+    
+    printf("RTC example\n"); 
+    set_time(1387188323); // Set RTC time to 16 December 2013 10:05:23 UTC
+    printf("Date and time are set.\n");
+
+    while(1) {
+
+        time_t seconds = time(NULL);
+
+        //printf("Time as seconds since January 1, 1970 = %d\n", seconds);
+        
+        printf("Time as a basic string = %s", ctime(&seconds));
+
+        //char buffer[32];
+        //strftime(buffer, 32, "%I:%M:%S %p\n", localtime(&seconds));
+        //printf("Time as a custom formatted string = %s", buffer);
+
+        myled = !myled;      
+        wait(1);
+    }
+}
diff -r 000000000000 -r a13634459c68 mbed-dev.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-dev.lib	Tue Jan 31 21:35:13 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-dev/#95d6b41a828b