Topic: Local switch error
Dear friends!
I expect local switches and apps the switches work synchronously,
but I don’t know where the error is, it failed, !!!
Can someone with high ability help? Thank you!
#define REMOTEXY_MODE__ESP8266WIFI_LIB_CLOUD
#include <ESP8266WiFi.h>
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "WR2"
#define REMOTEXY_WIFI_PASSWORD "edcbafde36"
#define REMOTEXY_CLOUD_SERVER "cloud.remotexy.com"
#define REMOTEXY_CLOUD_PORT 6376
#define REMOTEXY_CLOUD_TOKEN "1f3898d89cd3eee63ee639a077ad58ea"
int DD6=0;
int DD7=0;
int DD8=0;
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,6,0,0,0,252,0,10,13,1,
2,1,37,18,20,8,2,26,31,31,
79,78,0,79,70,70,0,2,1,37,
32,20,8,2,26,31,31,79,78,0,
79,70,70,0,2,1,36,47,21,8,
2,26,31,31,79,78,0,79,70,70,
0,2,1,36,62,21,8,2,26,31,
31,79,78,0,79,70,70,0,2,1,
36,77,21,8,2,26,31,31,79,78,
0,79,70,70,0,2,1,36,91,21,
9,2,26,31,31,79,78,0,79,70,
70,0,129,0,5,19,28,5,17,82,
101,108,97,121,32,48,49,32,45,45,
45,45,0,129,0,5,34,28,5,17,
82,101,108,97,121,32,48,50,32,45,
45,45,45,0,129,0,5,49,20,5,
17,82,101,108,97,121,32,48,51,32,
45,45,45,45,0,129,0,5,63,28,
5,17,82,101,108,97,121,32,48,52,
32,45,45,45,45,0,129,0,4,78,
20,5,17,82,101,108,97,121,32,48,
53,32,45,45,45,45,0,129,0,4,
92,28,5,17,82,101,108,97,121,32,
48,54,32,45,45,45,45,0,129,0,
4,0,54,8,15,83,105,120,32,82,
101,108,97,121,32,83,89,83,0 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
uint8_t switch_1; // =1 if switch ON and =0 if OFF
uint8_t switch_2; // =1 if switch ON and =0 if OFF
uint8_t switch_3; // =1 if switch ON and =0 if OFF
uint8_t switch_4; // =1 if switch ON and =0 if OFF
uint8_t switch_5; // =1 if switch ON and =0 if OFF
uint8_t switch_6; // =1 if switch ON and =0 if OFF
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
#define PIN_SWITCH_1 D0
#define PIN_SWITCH_2 D1
#define PIN_SWITCH_3 D2
#define PIN_SWITCH_4 D3
#define PIN_SWITCH_5 D4
#define PIN_SWITCH_6 D5
/*
#define PIN_IN_6 D6
#define PIN_IN_7 D7
#define PIN_IN_8 D8
*/
void setup()
{
RemoteXY_Init ();
pinMode (PIN_SWITCH_1, OUTPUT);
pinMode (PIN_SWITCH_2, OUTPUT);
pinMode (PIN_SWITCH_3, OUTPUT);
pinMode (PIN_SWITCH_4, OUTPUT);
pinMode (PIN_SWITCH_5, OUTPUT);
pinMode (PIN_SWITCH_6, OUTPUT);
pinMode (D6, INPUT);
pinMode (D7, INPUT);
pinMode (D8, INPUT);
// TODO you setup code
}
void loop() {
RemoteXY_Handler ();
digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);
digitalWrite(PIN_SWITCH_2, (RemoteXY.switch_2==0)?LOW:HIGH);
digitalWrite(PIN_SWITCH_3, (RemoteXY.switch_3==0)?LOW:HIGH);
digitalWrite(PIN_SWITCH_4, (RemoteXY.switch_4==0)?LOW:HIGH);
digitalWrite(PIN_SWITCH_5, (RemoteXY.switch_5==0)?LOW:HIGH);
digitalWrite(PIN_SWITCH_6, (RemoteXY.switch_6==0)?LOW:HIGH);
DD6=digitalRead(D6);
DD7=digitalRead(D7);
DD8=digitalRead(D8);
if(DD6 == HIGH){
if(digitalRead(PIN_SWITCH_1==HIGH)){ digitalWrite(PIN_SWITCH_1,LOW); }
else if(digitalRead(PIN_SWITCH_1==LOW)){ digitalWrite(PIN_SWITCH_1,HIGH); }}
else if(DD7 == HIGH){
if(digitalRead(PIN_SWITCH_2==HIGH)){ digitalWrite(PIN_SWITCH_2,LOW); }
else if(digitalRead(PIN_SWITCH_2==LOW)){ digitalWrite(PIN_SWITCH_2,HIGH); }}
else if(DD8 == HIGH){
if(digitalRead(PIN_SWITCH_3==HIGH)){ digitalWrite(PIN_SWITCH_3,LOW); }
else if(digitalRead(PIN_SWITCH_3==LOW)){ digitalWrite(PIN_SWITCH_3,HIGH); }}
else{}
// TODO you loop code
// use the RemoteXY structure for data transfer
// do not call delay()
}