This sketch set and arbitrary time and date, and then send through serial port every five seconds
Dependencies: Hotboards_rtcc mbed
Diff: main.cpp
- Revision:
- 2:374bbb14bb6a
- Parent:
- 1:d385e20a630f
--- a/main.cpp Tue Feb 09 22:46:13 2016 +0000 +++ b/main.cpp Wed Feb 10 01:38:52 2016 +0000 @@ -3,8 +3,10 @@ Demonstrates the use a MCP7941x clock calendar. The Hotboards_rtcc library works with this microchip real time clock (http://www.hotboards.org). + This sketch set and arbitrary time and date, and then send through serial port every five seconds + The circuit: * VDD --> 3.3v * GND --> GND @@ -14,6 +16,11 @@ #include "mbed.h" #include "Hotboards_rtcc.h" +/* days of the week */ +const char *week[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; +/* months of the year */ +const char *months[] = {"JAN","FEB","MAR","APR","MAY","JUN", "JUL", "AUG","SEPT","OCT","NOV","DEC"}; + /*serial port init*/ Serial pc(USBTX,USBRX); /*i2c instance delaration for use with the rtcc library*/ @@ -35,7 +42,7 @@ /* get the actual time and date */ DateTime time = rtcc.now( ); /* print to serial port */ - printf( "Time- %d:%d:%d Date- %d/ %d/ %d\n",time.hour( ),time.minute( ),time.second( ),time.day( ),time.month( ),time.year( )); + printf( "Time- %d:%d:%d Date- %s/ %d/ %s/ %d\n",time.hour( ),time.minute( ),time.second( ),week[time.dayOfTheWeek( )],time.day( ),months[time.month( )],time.year()); /* repeat again every 5 seconds*/ wait( 5 ); }