Uhr zeit

Ich suche eine Billige Methode die Uhrzeit herauszufinden (auf dem Arduino). Die habe ich gefunden:

#define secondPin 4
#define minutePin 5
#define hourPin 6
#define weekdayPin 7

int second=0, minute=0, hour=0, weekday=1;


void setup() {
Serial.begin(9600);
pinMode(secondPin, INPUT);
pinMode(minutePin, INPUT);
pinMode(hourPin, INPUT);
pinMode(weekdayPin, INPUT);
}

void loop() {

static unsigned long lastTick = 0; 

if (millis() - lastTick >= 1000) {
lastTick = millis();
serialOutput();
second++;
}

if (second > 59) {
minute++;
second = 0; 
}


if (minute > 59) {
hour++;
minute = 0; 
}


if (hour > 23) {
weekday++;
hour = 0;
}


if (weekday > 7) {
weekday = 1;
}

checkButtons(); 
}

void checkButtons() {

if (digitalRead (secondPin)==HIGH) {
second++;
}

if (digitalRead (minutePin)==HIGH) {
minute++;
}

if (digitalRead (hourPin)==HIGH) {
hour++;
}

if (digitalRead (weekdayPin)==HIGH) {
weekday++;
}
}

void printWeekday (int dayNum) {
  // print a weekday, based on the day number
  switch (dayNum) {
  case 1:
    Serial.print ("Sonntag");
    break;
  case 2:
    Serial.print ("Montag");
    break;
  case 3:
    Serial.print ("Dienstag");
    break;
  case 4:
    Serial.print ("Mittwoch");
    break;
  case 5:
    Serial.print ("Donnerstag");
    break;
  case 6:
    Serial.print ("Freitag");
    break;
  case 7:
    Serial.print ("Samstag");
    break;
  }
}

void serialOutput() {
// this function creates a clock you can read through the serial port
// your clock project will have a MUCH more interesting way of displaying the time
// get creative!
printWeekday(weekday); // picks the right word to print for the weekday
Serial.print(", "); // a comma after the weekday
Serial.print(hour, DEC); // the hour, sent to the screen in decimal format
Serial.print(":"); // a colon between the hour and the minute
Serial.print(minute, DEC); // the minute, sent to the screen in decimal format
Serial.print(":"); // a colon between the minute and the second
Serial.println(second, DEC); // the second, sent to the screen in decimal format
}

Aber die Methode ist irgend wie Merkwürzig gibt es eine billige Hardware Lösung? ich kenne das Real Time Shield aber auf watterott kostet das 16 €
Kennt jemand einen Chip der so was Drauf hat? (links von watterott und conrad sind gern gesehen^^)

Wie wäre es mit einem DCF-77 Modul um 5€? Braucht zwar ein Bißchen Programmierung, ist aber für Mitteleuropa gut.

Korman

sieht gut aus ich seh mir mal das Datenblatt an

Tach, eine Kombination aus DCF77-Modul und RTC-Baustein wie z.B. DS1307 oder PCF 8583 ist meiner meinung nach das beste und zusammen ca. 10€

Kannst du mir links geben?

DCF77:

http://arduino.cc/forum/index.php/topic,30255.0.html

PCF8583:
http://books.google.com/books?id=hIdBwUaSfWsC&lpg=PP1&dq=arduino%20praxiseinstieg&hl=de&pg=PA90#v=onepage&q&f=false
(Hier musst du auf Seite 98 aufpassen, da hat der Autor die Analogeingänge A4 und A5 vertauscht)
http://arduino.cc/forum/index.php/topic,54635.0.html