Sandro Juca
/
RTC_ArmBrazilPrintUSB
Set internal Arm RTC Mbed via USB. For more details: http://www.youtube.com/watch?v=v_dIJBSjnuM
Diff: main.cpp
- Revision:
- 0:7386564b4098
--- /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