Dependencies:   DS1307 RTC_sync mbed

Revision:
0:172604dcaa46
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RTC_synchroniseren.cpp	Tue Mar 24 08:31:30 2015 +0000
@@ -0,0 +1,59 @@
+ #include "ds1307.h"
+ #include "TextLCD.h"
+ #include "mbed.h"
+ 
+ Serial pc(USBTX, USBRX); // tx, rx  for debug and usb pc comunications
+ TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x4); // rs, e, d4-d7
+ DS1307 DS1307(p9,p10); // start DS1307 class and give it pins for connections of the DS1307 device
+
+ int sec = 0;       // Values to set time withppppppppppppp
+ int min = 20;
+ int hours = 13;
+ int day = 2;
+ int date = 23;
+ int month = 3;
+ int year = 15;
+ int prevSec = 0;
+
+ int main() {  
+ //gebruik onderstaande enkel om de RTC juist te zetten
+ DS1307.settime( sec, min, hours, day, date, month, year);    // Set the time on the DS1307
+     
+      DS1307.gettime( &sec, &min, &hours, &day, &date, &month, &year);  // Read the time and display on screen
+      pc.printf("seconds read are %.2D \n\r",sec);
+      pc.printf("min read are %.2D \n\r",min);
+      pc.printf("hour read are %.2D \n\r",hours);
+      pc.printf("day read are %.2D \n\r",day);
+      pc.printf("date read are %.2D \n\r",date);
+      pc.printf("month read are %.2D \n\r",month);
+      pc.printf("year read are %.2D \n\r",year);
+     
+     while (1){        // Loop continously
+        DS1307.gettime( &sec, &min, &hours, &day, &date, &month, &year);
+        
+        /*if (day == 1)
+            lcd.printf("   Sunday \n");
+        if (day == 2)
+            lcd.printf("   Monday \n");   
+        if (day == 3)
+            lcd.printf("   Tuesday \n");
+        if (day == 4)
+            lcd.printf("   Wednesday \n");
+        if (day == 5)
+            lcd.printf("   Thursday \n");
+        if (day == 6)
+            lcd.printf("   Friday \n");
+        if (day == 7)
+            lcd.printf("   Saturday \n");*/
+            
+        if (sec != prevSec){
+            pc.printf("seconds read are %.2D \n\r",sec);
+            pc.printf("min read are %.2D \n\r",min);
+            pc.printf("hour read are %.2D \n\r",hours);
+            pc.printf("day read are %.2D \n\r",day);
+            pc.printf("date read are %.2D \n\r",date);
+            pc.printf("month read are %.2D \n\r",month);
+            pc.printf("year read are %.2D \n\r",year);
+            prevSec = sec;}
+    }          
+ }
\ No newline at end of file