Jairo Rodriguez / Mbed 2 deprecated RTC

Dependencies:   RTC-DS1307 TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Rtc_Ds1307.h"
00003 #include "TextLCD.h"
00004 
00005  
00006 Rtc_Ds1307 rtc(PTE0, PTE1);
00007 TextLCD lcd(PTE5, PTE4, PTE3, PTE2, PTB11, PTB10); // rs, e, d4-d7
00008 Serial pc(USBTX, USBRX, "pc");
00009 
00010 int main(){
00011     Rtc_Ds1307::Time_rtc tm = {};
00012     rtc.startClock();
00013 
00014     while(1) {   
00015          
00016                     rtc.getTime(tm);
00017                     lcd.locate(0,0);
00018                     lcd.printf("Hora:%02d:%02d:%02d\n\r",tm.hour, tm.min, tm.sec); 
00019                     lcd.locate(0,1);                         
00020                     lcd.printf("Fech:%02d/%02d/%04d\n\r", tm.date, tm.mon, tm.year);
00021                     
00022                 }
00023             }