/* * TimeRTC.pde * Example code illustrating Time library with Real Time Clock. * This example is identical to the example provided with the Time Library, * only the #include statement has been changed to include the DS3232RTC library. */ #include //http://github.com/JChristensen/DS3232RTC #include //http://www.arduino.cc/playground/Code/Time #include //http://arduino.cc/en/Reference/Wire (included with Arduino IDE) void setup(void) { Serial.begin(9600); setSyncProvider(RTC.get); // the function to get the time from the RTC if(timeStatus() != timeSet) Serial.println("Unable to sync with the RTC"); else Serial.println("RTC has set the system time"); } void loop(void) { digitalClockDisplay(); tempfunc(); delay(1000); } void digitalClockDisplay(void) { // digital clock display of the time Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.print(' '); Serial.print(day()); Serial.print("/"); Serial.print(month()); Serial.print("/"); Serial.print(year()); Serial.println(); } // Temp Func Added by A.Tedds. void tempfunc(){ int t = RTC.temperature(); float celsius = t / 4.0; float fahrenheit = celsius * 9.0 / 5.0 + 32.0; Serial.print("Temperature "); Serial.print(fahrenheit); Serial.print("F "); Serial.print(celsius); Serial.println("C"); } void printDigits(int digits) { // utility function for digital clock display: prints preceding colon and leading 0 Serial.print(':'); if(digits < 10) Serial.print('0'); Serial.print(digits); }