Ds1307
Dependencies: RTC-DS1307 TextLCD mbed
main.cpp@0:0616025d9f54, 2015-06-08 (annotated)
- Committer:
- jyrodriguezg
- Date:
- Mon Jun 08 00:43:27 2015 +0000
- Revision:
- 0:0616025d9f54
Ds1307
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jyrodriguezg | 0:0616025d9f54 | 1 | #include "mbed.h" |
jyrodriguezg | 0:0616025d9f54 | 2 | #include "Rtc_Ds1307.h" |
jyrodriguezg | 0:0616025d9f54 | 3 | #include "TextLCD.h" |
jyrodriguezg | 0:0616025d9f54 | 4 | |
jyrodriguezg | 0:0616025d9f54 | 5 | |
jyrodriguezg | 0:0616025d9f54 | 6 | Rtc_Ds1307 rtc(PTE0, PTE1); |
jyrodriguezg | 0:0616025d9f54 | 7 | TextLCD lcd(PTE5, PTE4, PTE3, PTE2, PTB11, PTB10); // rs, e, d4-d7 |
jyrodriguezg | 0:0616025d9f54 | 8 | Serial pc(USBTX, USBRX, "pc"); |
jyrodriguezg | 0:0616025d9f54 | 9 | |
jyrodriguezg | 0:0616025d9f54 | 10 | int main(){ |
jyrodriguezg | 0:0616025d9f54 | 11 | Rtc_Ds1307::Time_rtc tm = {}; |
jyrodriguezg | 0:0616025d9f54 | 12 | rtc.startClock(); |
jyrodriguezg | 0:0616025d9f54 | 13 | |
jyrodriguezg | 0:0616025d9f54 | 14 | while(1) { |
jyrodriguezg | 0:0616025d9f54 | 15 | |
jyrodriguezg | 0:0616025d9f54 | 16 | rtc.getTime(tm); |
jyrodriguezg | 0:0616025d9f54 | 17 | lcd.locate(0,0); |
jyrodriguezg | 0:0616025d9f54 | 18 | lcd.printf("Hora:%02d:%02d:%02d\n\r",tm.hour, tm.min, tm.sec); |
jyrodriguezg | 0:0616025d9f54 | 19 | lcd.locate(0,1); |
jyrodriguezg | 0:0616025d9f54 | 20 | lcd.printf("Fech:%02d/%02d/%04d\n\r", tm.date, tm.mon, tm.year); |
jyrodriguezg | 0:0616025d9f54 | 21 | |
jyrodriguezg | 0:0616025d9f54 | 22 | } |
jyrodriguezg | 0:0616025d9f54 | 23 | } |