 // Boolean Felder Raten.
 boolean floor_og=false;
 boolean floor_eg=false;
-
-char mode[4]; // ein Reservierter Speicher fuer Modus ON / OFF
+boolean chkfix=true;
+
 unsigned long relaistime = 60000L; // Schalte die Relais Versorgungsspannung nach 1min. ab.
 // Wie lange das Relais den Status ON hat bis es wieder abgeschalten wird. Somit kann es
 // einen bestimmten Weg zuruecklegen.

  }
}


void loop() {
  unsigned long currmillis = millis();

  // weg von der Winde zum 1.OG
  if (floor_eg == false && floor_og == false && S2State == true) {
    if ((unsigned long)(currmillis - task2) >= worktime) {
      if ( S1State == true || S2State == true ) {
        //Serial.println("Switch Relais after worktime OFF");
        SecRelais1("OFF");
        SecRelais2("OFF");
        floor_og=true;
      }
    }
    // weg vom 1.OG nach EG
  } else if (floor_eg == false && floor_og == true && S2State == true) {
    if ((unsigned long)(currmillis - task2) >= worktimeto_eg) {
      if ( S1State == true || S2State == true ) {
        //Serial.println("Switch Relais after worktime OFF");
        SecRelais1("OFF");
        SecRelais2("OFF");
        floor_eg=true;
      }
    }
    // zueruck auf das 1.OG
  } else if (floor_eg == true && floor_og == true && S1State == true) {
    if ((unsigned long)(currmillis - task2) >= worktimeto_eg) {
      if ( S1State == true || S2State == true ) {
        //Serial.println("Switch Relais after worktime OFF");
        SecRelais1("OFF");
        SecRelais2("OFF");
        floor_eg=false;
      }
    }
    // zurueck auf start
  } else if (floor_eg == false && floor_og == true && S1State == true) {
    if ((unsigned long)(currmillis - task2) >= worktime) {
      if ( S1State == true || S2State == true ) {
        //Serial.println("Switch Relais after worktime OFF");
        SecRelais1("OFF");
        SecRelais2("OFF");
        floor_og=false;
      }
    }
  } 
  
  // schalte das Relais nach eingestellter Zeit aus
  if ((unsigned long)(currmillis - task2) >= relaistime) {
    if (ROState == true) {
      //Serial.println("switch Relais OFF");
      SWRelais("OFF");
    }
  }
}


    digitalWrite(RO, HIGH);
    ROState=false;
  }
}


void SecRelais1(char mode[3]){
  /*
   * Relais 1 with state check (DOWN)
   */
  if (mode == "ON") {
    //Serial.println(F("SecRelais1 = mode ON"));
    if (S1State == false && S2State == false) {
      //Serial.println(F("SecRelais1 = ON, state = true"));
      S1State=true;
      digitalWrite(S1, LOW);
    } else if (S1State == false && S2State == true) {
      //Serial.println(F("SecRelais1 = ON, state = true"));
      digitalWrite(S2, HIGH);
      S2State=false;
      delay(80);
      S1State=true;
      digitalWrite(S1, LOW);
    } else if (S1State == true && S2State == false) {
      // do nothing
    }
  } else {
    //Serial.print(F("SecRelais1 mode = "));
    //Serial.println(mode);
    digitalWrite(S1, HIGH);
    S1State=false;
  }
}


void SecRelais2(char mode[3]) {
  /*
   * Relais 2 with state check (UP)
   */
  if (mode == "ON") {
    if (S2State == false && S1State == false) {
      //Serial.println(F("SecRelais2 = ON, state = true"));
      S2State=true;
      digitalWrite(S2, LOW);
    } else if (S2State == false && S1State == true) {
      //Serial.println(F("SecRelais1 = ON, state = true"));
      digitalWrite(S1, HIGH);
      S1State=false;
      delay(80);
