Sandro Juca
/
RTC_ArmBrazilPrintUSB
Set internal Arm RTC Mbed via USB. For more details: http://www.youtube.com/watch?v=v_dIJBSjnuM
main.cpp
- Committer:
- sandrojuca
- Date:
- 2013-09-18
- Revision:
- 0:7386564b4098
File content as of revision 0:7386564b4098:
#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 } }