Ich habe die RTC natürlich selbst gebaut. Nagut, so natürlich ist das nicht, Segor um die Ecke hat natürlich nur den Chip und kein Shield. Quarz habe ich dort auch gekauft und es ist eines mit 12pF. Alternativ habe ich aus einem uralt Mainboard noch ein zweites Quarz zum probieren eingelötet.
Schaltung ist die folgende:
allerdings habe ich noch einen Pullup der SQRT quelle spendiert.
Müsste ich den Datenbus nicht über das Oszilluskop messen können?
Stefan
Quellcode ist der folgende
/*
* TimeRTC.pde
* example code illustrating Time library with Real Time Clock.
*
*/
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
void setup() {
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()
{
digitalClockDisplay();
delay(1000);
}
void digitalClockDisplay(){
// 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();
}
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);
}
Zurücke kommt:
"RTC has set the system time
0:00:00: 1 1 2000"
Gehe ich richtig in der Annahme, dass in "#include <Wire.h> " die richtigen Pins vom Megaboard stehen bzw von dort weiter verwiesen wird?