//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP8266_HARDSERIAL_POINT
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_SERIAL Serial
#define REMOTEXY_SERIAL_SPEED 115200
#define REMOTEXY_WIFI_SSID "UsingSelectButton"
#define REMOTEXY_WIFI_PASSWORD ""
#define REMOTEXY_SERVER_PORT 6377
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,3,0,0,0,45,0,8,13,0,
2,0,4,7,22,11,2,26,31,31,
79,78,0,79,70,70,0,2,0,4,
25,22,11,2,26,31,31,79,78,0,
79,70,70,0,3,3,5,39,8,22,
2,26 };
// this structure defines all the variables of your control interface
struct {
// input variable
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 select_1; // =0 if select position A, =1 if position B, =2 if position C, ...
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
#define PIN_SWITCH_1 2
#define PIN_SWITCH_2 2
#define PIN_SELECT_1 2
int i;
void setup()
{
RemoteXY_Init ();
pinMode (PIN_SWITCH_1, OUTPUT);
pinMode (PIN_SWITCH_2, OUTPUT);
pinMode (PIN_SELECT_1, OUTPUT);
// TODO you setup code
}
void loop()
{
RemoteXY_Handler ();
digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?HIGH:LOW);
if(RemoteXY.switch_1==1)
{
digitalWrite (PIN_SWITCH_1, HIGH);//Lampu Switch Mati
delay(1000);
digitalWrite (PIN_SWITCH_1, LOW);//Lampu Switch Hidup
delay(3000);
}
digitalWrite(PIN_SWITCH_2, (RemoteXY.switch_2==0)?HIGH:LOW);
if(RemoteXY.switch_2==1)
{
digitalWrite (PIN_SWITCH_2, HIGH);//Lampu Switch Mati
delay(500);
digitalWrite (PIN_SWITCH_2, LOW);//Lampu Switch Hidup
delay(500);
}
//Select Button Code
digitalWrite(PIN_SWITCH_1, (RemoteXY.select_1==0)?HIGH:LOW);
if(RemoteXY.select_1==1)
{
for(i=0; i<5; i++)
{
digitalWrite(PIN_SWITCH_1,HIGH);
delay(500);
digitalWrite(PIN_SWITCH_1,LOW);
delay(500);
}
delay(10000);
}
if(RemoteXY.select_1==2)
{
digitalWrite(PIN_SELECT_1,HIGH);
delay(1000);
digitalWrite(PIN_SELECT_1,LOW);
delay(3000);
}
// TODO you loop code
// use the RemoteXY structure for data transfer
}