// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP32CORE_WIFI_POINT
#include <WiFi.h>
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "RemoteXY"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377
// RemoteXY configurate
#pragma pack (push, 1)
uint8_t RemoteXY_CONF [] =
{255,7,0,27,0,172,1,8,24,5,
130,1,21,71,21,29,2,0,130,1,
3,21,21,79,2,0,130,1,39,21,
21.79,2,0,130,1,0,0,63,7,
0,0,131,1,52,1,10,5,1,2,
31,216,167,217,132,216,168,216,175,216,
167,217,138,216,169,0,130,1,1,1,
50,5,0,16,131,0,32,1,9,5,
2,2,31,49,0,131,0,22,1,9,
5,3,2,31,50,0,131,0,12,1,
9,5,4,2,31,51,0,131,0,2,
1,9,5,5,2,31,52,0,129,0,
42,2,8,3,0,24,216,167,217,132,
216,170,217,133,216,167,216,177,217,138,
217,134,0,130,1,0,7,63,14,2,
0,2,0,1,8,11,5,2,2,26,
31,31,79,78,0,79,70,70,0,2,
0,13,8,11,5,2,2,2,26,31,31,
79,78,0,79,70,70,0,2,0,25,
8,11,5,2,2,26,31,31,79,78,
0.79,70,70,0,2,0,37,8,11,
5,2,2,26,31,31,79,78,0,79,
70,70,0,65,4,3,13,7,7,2,
129,0,5,14,3,6,2,17,52,0,
65,4,39,13,7,7,2,65,4,27,
13,7,7,2,65,4,15,13,7,7,
2,129,0,17,14,3,6,2,17,51,
0,129,0,29,14,3,6,2,17,50,
0,129,0,41,14,3,6,2,17,49,
0,129,0,49,13,10,4,2,24,216,
167,217,132,216,163,217,135,216,175,216,
167,217,129,0,2,1,25,74,13,14,
2,2,26,31,31,79,78,0,79,70,
70,0,4,0,9,27,9,65,2,2,
26,67,5,6,22,15,5,2,2,26,
11.67.5,42,22,15,5,2,2,26,
11,4,0,45,27,9,65,2,2,26,
129,0,41,94,16,4,2,31,216,178,
217,133,217,134,32,216,167,217,132,216,
170,216,180,216,186,217,138,217,132,0,
129,0,5,94,16,4,2,31,216,178,
217,133,217,134,32,216,167,217,132,216,
170,217,136,217,130,217,129,0,65,2,
27.89,9,9,2};
// this structure defines all the variables of your control interface
struct {
// input variable
uint8_t sw1_4; // = 1 if switch ON and = 0 if OFF
uint8_t sw1_3; // = 1 if switch ON and = 0 if OFF
uint8_t sw1_2; // = 1 if switch ON and = 0 if OFF
uint8_t sw1_1; // = 1 if switch ON and = 0 if OFF
uint8_t switch_1; // = 1 if switch ON and = 0 if OFF
int8_t s1_2; // = 0..100 slider position
int8_t s1_1; // = 0..100 slider position
// output variable
uint8_t l1_4_r; // = 0..255 LED Red brightness
uint8_t l1_1_r; // = 0..255 LED Red brightness
uint8_t l1_2_r; // = 0..255 LED Red brightness
uint8_t l1_3_r; // = 0..255 LED Red brightness
char t1_2 [11]; // string UTF8 end zero
char t1_1 [11]; // string UTF8 end zero
uint8_t led_1_g; // = 0..255 LED Green brightness
// other variable
uint8_t connect_flag; // = 1 if wire connected, else = 0
} RemoteXY;
#pragma pack (pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
float OnTime = 0; // i add this line
float OffTime = 0; // i add this line
int ledPin1 = 6; // i add this line
int ledPin2 = 7; // i add this line
int ledState1 = LOW; // i add this line
int ledState2 = LOW; // i add this line
unsigned long previousMillis2 = 0; // i add this line
unsigned long previousMillis1 = 0; // i add this line
unsigned long currentMillis = millis (); // i add this line
void setup ()
{
RemoteXY_Init ();
pinMode (6, OUTPUT);
pinMode (7, OUTPUT);
// TODO you setup code
}
void loop ()
{
RemoteXY_Handler ();
OnTime = map (RemoteXY. S1_1, 0, 100, 0, 5000); // i add this line
float v1_1n = OnTime / 1000; // i add this line
dtostrf (v1_1n, 0, 1, RemoteXY.t1_1); // i add this line
OffTime = map (RemoteXY. S1_2, 0, 100, 0, 5000); // i add this line
float v1_2n = OffTime / 1000; // i add this line
dtostrf (v1_2n, 0, 1, RemoteXY.t1_2); // i add this line
if (RemoteXY.switch_1 == 1) { // i add this line
if ((ledState1 == HIGH) && (currentMillis - previousMillis1> = OnTime)) {ledState1 = LOW; previousMillis1 = currentMillis; digitalWrite (ledPin1, ledState1);} // i add this line
else if ((ledState1 == LOW) && (currentMillis - previousMillis1> = OffTime)) {ledState1 = HIGH; previousMillis1 = currentMillis; digitalWrite (ledPin1, ledState1);} // i add this line
if ((ledState2 == HIGH) && (currentMillis - previousMillis2> = OnTime)) {ledState2 = LOW; previousMillis2 = currentMillis; digitalWrite (ledPin2, ledState2);} // i add this line
else if ((ledState2 == LOW) && (currentMillis - previousMillis2> = OffTime)) {ledState2 = HIGH; previousMillis2 = currentMillis; digitalWrite (ledPin2, ledState2);} // i add this line
; } // i add this line
else {digitalWrite (6,0); digitalWrite (7,0);} // i add this line
// TODO you loop code
// use the RemoteXY structure for data transfer
} [/ code]