Go Down

Topic: Sketch for shutter control (Read 225 times) previous topic - next topic

rogim

Hello,
I have a sketch for my roller shutter control.
The following part of the sketch switches on with a push button relay 1. If the 2nd relay is switched on, relay 1 will be switched off before relay 2
on.
Now I would like to implement a time limit of 30 seconds. The 2 relays will turn off automatically after 30 seconds. During this time, however, the former function should remain.
Can you help me there?
Thank you for that


 if (!digitalRead(Taster1)) //Taster betätigt
  {
    delay(50);
    if (!digitalRead(Taster1)) // Nach 100mS immer noch betätigt dann ist es keine Induktionstrom in der Leitung
    {
      val[0] = !val[0];
    //  digitalWrite(Relay1, active_low ^ val[0]);                                                                   // Änderung 
    if (val[1])             // wenn  Relais 2 is on
{
val[1]=0;                          //relais 2 switch off (wert setzen )
digitalWrite(Relay2, active_low ^ val[1]); // (ausführen)
delay(500);                          // 0,5 sekunden warten
}
digitalWrite(Relay1, active_low ^ val[0]); // now  Relais 1 witch on
   
      Temp = PrintDate(now()) + "   " + PrintTime (now()) + "   Relais: 1";
      if (val[0]) Temp += " ON ";
      else Temp += " OFF";
      Temp += "     ";
      Temp += "Taster";
      Temp += "\r\n";
      LogSchreiben(Temp);
      while (!digitalRead(Taster1))server.handleClient(); // Warten bis der Taster losgelassen wird
    }
  }

  if (!digitalRead(Taster2)) //Taster betätigt
  {
    delay(50);
    if (!digitalRead(Taster2)) // Nach 100mS immer noch betätigt dann ist es keine Induktionstrom in der Leitung
    {
      val[1] = !val[1];
      //digitalWrite(Relay2, active_low ^ val[1]);
      if (val[0])             // wenn  Relais1 ist an
{
val[0]=0;                          //relais 1 auschalten (wert setzen )
digitalWrite(Relay1, active_low ^ val[0]); // (ausführen)
delay(500);                          // 0,5 sekunden warten
}
digitalWrite(Relay2, active_low ^ val[1]); // erst jetzt Relais 2 einschalten

      Temp = PrintDate(now()) + "   " + PrintTime (now()) + "   Relais: 2";
      if (val[0]) Temp += " ON ";
      else Temp += " OFF";
      Temp += "     ";
      Temp += "Taster";
      Temp += "\r\n";
      LogSchreiben(Temp);
      while (!digitalRead(Taster2))server.handleClient(); // Warten bis der Taster losgelassen wird
    }
  }

aarg

You have not posted your entire sketch. Please repost or post again using code tags, as explained in the sticky posts at the top of the forum.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

rogim

In the attachment is the entire sketch.

The sketch is for 4 relays. However, I only need 2 relays.

Control with the buttons starts from line 315.

If I have a solution for the buttons, I think that it is sufficient for the control from the Internet or for the time control to transfer the changed lines there.

Many Thanks

aarg

You're modifying someone else's sketch? Have you been able to make it work as it is?
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

rogim

OK, I want to ask him. Please delete the post until I have received an answer. Then I will come back.

aarg

OK, I want to ask him. Please delete the post until I have received an answer. Then I will come back.
There is no need to delete it. Just bookmark it in your browser and update the same thread whenever you are ready.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

Coding Badly

#6
Jan 14, 2018, 08:25 pm Last Edit: Jan 14, 2018, 08:26 pm by Coding Badly
Please delete the post until I have received an answer.
You have the ability to do it yourself.

Or, are you asking to have the thread removed?


Go Up