Also der Motor hängt an pin 8,9,10,11
und der Taster an Pin 4
#include <Time.h>
#include <DCF77.h>
#include <Utils.h>
#include <Stepper.h>
// change this to the number of steps on your motor
// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(100, 8, 9, 10, 11);
boolean debug = true;
int serspeed = 9600 ;
int StandortErde = 0;
int zaehler = 0;
#define DCF_PIN 2 // Connection pin to DCF 77 device
#define DCF_INTERRUPT 0 // Interrupt number associated with pin
time_t time;
DCF77 DCF = DCF77(DCF_PIN,DCF_INTERRUPT);
void setup()
{
Serial.begin(serspeed);
stepper.setSpeed(1);
if(debug)
{
Serial.println("Debugging aktiviert");
}
DCF.Start();
}
void loop(){
time_t DCFtime = DCF.getTime(); // Check if new DCF77 time is available
if ((DCFtime!=0) && (debug = true))
{
Serial.println("Time is updated");
setTime(DCFtime);
}
digitalClockDisplay();
if(debug = true){
// Serial.print("Zähler: ");
//Serial.println(zaehler);
Serial.print("Standort: ");
Serial.println(digitalRead(4));
}
StandortErde = digitalRead(4);
if (StandortErde == HIGH){
stepper.setSpeed(1);
stepper.step(1);
zaehler = zaehler + 1;
}
else{
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
zaehler = 0;
}
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);
}