1

Topic: Ask code for Auto Switch Changing

Please help . . .
what is code for control Switch Button RemoteXY, if :
1. in RemoteXY Have 2 Button or more
2. in Arduino only use 1 Relay
And it should When Switch_1 display ON, Display Switch_2 & Switch_3 should be OFF, and also when Display Switch_2 ON, Display Switch_1 dan Display Switch_3 will be off automatically

Thank Before from me (a newbie)

2

Re: Ask code for Auto Switch Changing

Welcome,

Sadly it's still not possible to do this simple thing (has been requested since years).

3

Re: Ask code for Auto Switch Changing

Thank you for ur replay

Guillaume wrote:

Welcome,

Sadly it's still not possible to do this simple thing (has been requested since years).

4

Re: Ask code for Auto Switch Changing

NP, see here for a workaround : http://forum.remotexy.com/viewtopic.php?pid=2081#p2081

5 (edited by albatros 2019-06-03 01:53:24)

Re: Ask code for Auto Switch Changing

I Would try using Select Button for relay, but why I cant control it,
and this the code
My Goal is give 2 or more Different command from 1 Relay

/*
#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,2,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


void setup() 
{
  RemoteXY_Init (); 
   
  pinMode (PIN_SWITCH_1, OUTPUT);
  pinMode (PIN_SWITCH_2, 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);
    }   

//code for select button
    switch(RemoteXY.select_1==0);
     {digitalWrite (PIN_SWITCH_1, HIGH);
     delay(1000);//Lampu Switch Mati
     digitalWrite (PIN_SWITCH_1, LOW);
     delay(3000);//Lampu Switch Hidup
     }
    switch(RemoteXY.select_1==1);
    {digitalWrite(PIN_SWITCH_1, (RemoteXY.select_1==1));
    digitalWrite (PIN_SWITCH_1, HIGH);//Lampu Switch Mati
    delay(500);
    digitalWrite (PIN_SWITCH_1, LOW);//Lampu Switch Hidup
    delay(500);
    }
  // TODO you loop code
  // use the RemoteXY structure for data transfer
}

6 (edited by Guillaume 2019-06-03 13:55:31)

Re: Ask code for Auto Switch Changing

You use 'switch' incorrectly

switch( RemoteXY.select_1 )
{
    case 0 :
    {
        digitalWrite (PIN_SWITCH_1, HIGH);
        delay(1000);//Lampu Switch Mati
        digitalWrite (PIN_SWITCH_1, LOW);
        delay(3000);//Lampu Switch Hidup
        break;
    }

    case 1 :
    {
        digitalWrite (PIN_SWITCH_1, HIGH);//Lampu Switch Mati
        delay(500);
        digitalWrite (PIN_SWITCH_1, LOW);//Lampu Switch Hidup
        delay(500);
        break;
    }
}