Guten Abend,
ich bin totaler Anfänger und möchte dennoch eine kleine Steuerung für ein Tor Basteln.
Es funktioniert alles bis auf die Zeiten, die varieren Stark.
Eingestellt sind 5000ms / dennoch schaltet das Tor mal nach 1sek, 2sek, 4sek... ab, verstehe leider nicht warum
generelle funktion :
Ich habe 2 Taster für AUF, und 2 Taster für ZU.
Der Erste Taster ist einfach nur ein Taster ..
Solange Taster gedrückt, TOR Fährt.
2ter Taster=Automatik, Tor Fährt die eingestellte Zeit und Stopt dann.
Das gleiche für zu natürlich.
Viele Grüße
Christian
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP8266WIFI_LIB
#include <ESP8266WiFi.h>
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "--"
#define REMOTEXY_WIFI_PASSWORD "--"
#define REMOTEXY_SERVER_PORT 6377
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] = // 546 bytes
{ 255,13,0,3,0,27,2,16,31,5,1,3,27,86,34,12,0,40,31,0,
130,1,0,9,63,27,1,54,130,1,0,36,63,19,1,180,130,0,0,55,
63,29,1,96,1,1,43,56,12,12,1,2,31,0,1,1,43,71,12,12,
1,2,31,0,129,0,18,60,21,6,1,8,84,111,114,32,65,117,102,0,
129,0,19,74,18,6,1,8,84,111,114,32,90,117,0,129,0,1,98,12,
2,0,17,65,114,100,117,105,110,111,32,86,51,46,49,0,1,0,24,38,
12,12,1,134,31,0,129,0,2,37,14,6,1,8,76,105,99,104,116,0,
129,0,15,0,33,6,1,8,72,97,117,112,116,109,101,110,195,188,0,1,
0,9,10,12,12,1,2,31,0,1,0,9,23,12,12,1,2,31,0,129,
0,22,13,18,6,1,8,65,117,102,0,129,0,23,26,7,6,1,8,90,
117,0,129,0,40,11,19,4,1,1,65,117,116,111,109,97,116,105,107,0,
129,0,37,89,13,6,0,1,83,116,111,112,0,129,0,1,56,12,4,1,
8,84,105,112,112,101,110,0,131,1,1,86,24,5,1,2,31,72,97,117,
112,116,109,101,110,195,188,0,131,0,1,92,24,5,2,2,31,69,105,110,
115,116,101,108,108,117,110,103,101,110,0,129,0,3,20,31,6,2,17,65,
117,102,102,97,104,114,122,101,105,116,0,129,0,3,30,18,6,2,17,90,
117,102,97,104,114,122,101,105,116,0,129,0,13,3,39,6,2,17,69,105,
110,115,116,101,108,108,117,110,103,101,110,0,7,52,38,20,20,5,2,2,
26,2,7,52,38,30,20,5,2,2,26,2,70,16,1,13,7,7,1,26,
37,0,70,16,1,26,7,7,1,26,37,0,70,16,4,43,9,9,1,27,
121,0,1,0,43,38,12,12,1,37,31,0,129,0,27,51,5,4,1,8,
69,105,110,0,129,0,46,51,7,4,1,8,65,117,115,0,129,0,3,39,
30,5,2,17,76,105,99,104,116,32,65,78,32,90,101,105,116,0,7,52,
38,38,20,5,2,2,26,2,129,0,1,51,39,5,2,8,90,101,105,116,
101,110,32,115,105,110,100,32,105,110,32,109,115,0,129,0,1,63,53,5,
2,8,49,48,48,48,48,109,115,61,49,48,83,101,107,117,110,100,101,110,
0,129,0,1,57,47,5,2,8,49,48,48,48,109,115,61,49,83,101,107,
117,110,100,101,110,0 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
uint8_t Stop; // =1 if button pressed, else =0
uint8_t Auf_Tippen; // =1 if button pressed, else =0
uint8_t zu; // =1 if button pressed, else =0
uint8_t Licht_Ein; // =1 if button pressed, else =0
uint8_t Auto_Auf; // =1 if button pressed, else =0
uint8_t Auto_ZU; // =1 if button pressed, else =0
int16_t Auffahrzeit; // 32767.. +32767
int16_t Zufahrzeit; // 32767.. +32767
uint8_t Licht_Aus; // =1 if button pressed, else =0
int16_t Licht_Zeit; // 32767.. +32767
// output variables
uint8_t led_1; // led state 0 .. 1
uint8_t led_2; // led state 0 .. 1
uint8_t led_3; // led state 0 .. 1
uint8_t Ausgang_Tippen_Auf; // =1 if button pressed, else =0
uint8_t Ausgang_Auto_Auf; // =1 if button pressed, else =0
uint8_t Ausgang_Tippen_zu;
uint8_t Ausgang_Auto_zu;
uint8_t Ausgang_STOP;
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
unsigned long previousMillisZU = 0;
unsigned long previousMillisAUF = 0;
unsigned long previousMillisLICHT = 0;
void setup()
{
RemoteXY_Init ();
//AUSGÄNGE
pinMode (D5, OUTPUT);
pinMode (D6, OUTPUT);
// TODO you setup code
}
void loop()
{
RemoteXY_Handler ();
//ZEITEINSTELLUNGEN HANDY!----------------------------------
const long intervalZU = RemoteXY.Zufahrzeit; // handy eingabe ist 5000
const long intervalAUF = RemoteXY.Auffahrzeit; // handy eingabe ist 5000
const long intervalLICHT = RemoteXY.Licht_Zeit;
//ZEITEINSTELLUNGEN HANDY ENDE!--------------------------------
//STOP------------------------
if (RemoteXY.Stop!=0){ //STOP TASTE
RemoteXY.Ausgang_STOP = HIGH; // STOP Variable SETZEN
}
//STOP ENDE------------------------
/////////////////////////////////////////////
// TOR AUF //
/////////////////////////////////////////////
//Schalter tippen auf
if (RemoteXY.Auf_Tippen!=0) {//Schalter tippen auf
RemoteXY.Ausgang_Tippen_Auf = HIGH; // VAriable setzen
}else { // else
RemoteXY.Ausgang_Tippen_Auf = LOW; // VAriable zurücksetzen
}
//schalter Auto Auf
if (RemoteXY.Auto_Auf!=0){ //Schalter auf am Handy
RemoteXY.Ausgang_Auto_Auf = HIGH; // Variable Setzen
RemoteXY.led_1 = HIGH;
}
//Zeitbaustein für AUF
unsigned long currentMillisAUF = millis();
if (currentMillisAUF - previousMillisAUF >= intervalAUF){
previousMillisAUF = currentMillisAUF;
RemoteXY.Ausgang_Auto_Auf = LOW; //variable nach zeit zurücksetzen
RemoteXY.led_1 = LOW; //led am handy aus
RemoteXY.Ausgang_STOP = LOW; // STOP variable nach zeit zurücksetzen
}
// Schalter tippen oder auto sendet das signal
if (RemoteXY.Ausgang_STOP==0 && RemoteXY.Ausgang_Tippen_Auf ||RemoteXY.Ausgang_STOP==0 && RemoteXY.Ausgang_Auto_Auf)
//Ausgänge
digitalWrite(D5, LOW);
else
digitalWrite(D5, HIGH);
/////////////////////////////////////////////
// TOR AUF ENDE //
/////////////////////////////////////////////
//-------------------------------------------------------------------------------------------
/////////////////////////////////////////////
// TOR ZU //
/////////////////////////////////////////////
//Schalter tippen zu
if (RemoteXY.zu!=0) {//zu tippen taste am Handy ---wenn
RemoteXY.Ausgang_Tippen_zu = HIGH; // Variable Setzen
}else { //--- sonst
RemoteXY.Ausgang_Tippen_zu = LOW; // Variable zurücksetzen
}
//schalter Auto zu
if (RemoteXY.Auto_ZU!=0){ //Schalter auto zu am handy
RemoteXY.Ausgang_Auto_zu = HIGH; // Variable Setzen
RemoteXY.led_2 = HIGH; //handy led Anzeige
}
//Zeitbaustein für ZU
unsigned long currentMillisZU = millis();
if (currentMillisZU - previousMillisZU >= intervalZU){
previousMillisZU = currentMillisZU;
RemoteXY.Ausgang_Auto_zu = LOW;
RemoteXY.led_2 = LOW;
RemoteXY.Ausgang_STOP = LOW; // STOP variable zurücksetzen
}
// Schalter tippen oder auto sendet das signal
if (RemoteXY.Ausgang_STOP==0 && RemoteXY.Ausgang_Tippen_zu ||RemoteXY.Ausgang_STOP==0 && RemoteXY.Ausgang_Auto_zu)
//Ausgänge
digitalWrite(D6, LOW); //AUSGANG AUS verwirrt weil relais gedreht sind
else
digitalWrite(D6, HIGH); //AUSGANG AN
/////////////////////////////////////////////
// TOR ZU Ende //
/////////////////////////////////////////////
//-------------------------------------------------------------------------------------------
//LICHT--------------------------------------------------------------------
if (RemoteXY.Licht_Ein!=0){ //licht an taste
//RemoteXY.Ausgang_Auto_zu = HIGH; // then turn on red light
RemoteXY.led_3 = HIGH; //handy LED EIN
}
if (RemoteXY.Licht_Aus!=0){ //Licht aus taste
//RemoteXY.Ausgang_Auto_zu = HIGH; // then turn on red light
RemoteXY.led_3 = LOW; //handy LED AUS
}
//LICHT ENDE--------------------------------------------------------------------
// TODO you loop code
// use the RemoteXY structure for data transfer
// do not call delay(), use instead RemoteXY_delay()
}