Set internal Arm RTC Mbed via USB. For more details: http://www.youtube.com/watch?v=v_dIJBSjnuM

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
sandrojuca
Date:
Wed Sep 18 23:47:04 2013 +0000
Commit message:
Set internal Arm RTC Mbed via USB. For more details: http://www.youtube.com/watch?v=v_dIJBSjnuM

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 Sep 18 23:47:04 2013 +0000
@@ -0,0 +1,25 @@
+#include "mbed.h" //Set internal Arm RTC Mbed via USB. For more details: http://www.youtube.com/watch?v=v_dIJBSjnuM
+//#include "TextLCD.h" 
+//TextLCD lcd(p19, p20, p21, p22, p23, p24); // rs, e, d0-d3 // www.sanusb.blogspot.com.br
+
+DigitalOut led(LED1);
+
+char time_stamp[18];//as our lcd is of 16 character it is so
+
+int main() 
+{
+    set_time(1379546354);  // Set RTC time http://www.epochconverter.com/
+
+    while (true) 
+    {
+        time_t seconds = time(NULL) - 10800; // time(null) gives the GMT time; Brazil(- 3hours = 10.800s): http://www.epochconverter.com/
+        strftime(time_stamp, 17, "%d.%m.%y %H:%M:%S", localtime(&seconds)); 
+        //this converts the value in seconds obtained above to human readable format and assigns it to the timestamp 
+
+        wait(1);
+        led =! led;
+        printf("%s\r\n",time_stamp);//displays via USB
+        //lcd.locate(0,0);//start displaying from zeroth column,zeroth row
+        //lcd.printf("%s",time_stamp);//diplays the human readable time
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Sep 18 23:47:04 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9c8f0e3462fb
\ No newline at end of file