1

Topic: all buttons off?

hi
im making a control panel for in my truck for when im camping ... basically i have 8 buttons to turn things via relays on and off - eg tent light or water pump etc, all is working at the moment but i require a 'all off' button that turns all the relays off at once (just in case summut goes tits up) and also turns all the buttons off (go red) on the phone .. i would appreciate if some one could point me in the right direction... my code is as follows ....

/*
   -- car project3 --
   
   This source code of graphical user interface
   has been generated automatically by RemoteXY editor.
   To compile this code using RemoteXY library 3.1.8 or later version
   download by link http://remotexy.com/en/library/
   To connect using RemoteXY mobile app by link http://remotexy.com/en/download/                   
     - for ANDROID 4.11.1 or later version;
     - for iOS 1.9.1 or later version;
   
   This source code is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.   
*/

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__SOFTSERIAL
#include <SoftwareSerial.h>

#include <RemoteXY.h>

// RemoteXY connection settings
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600


// RemoteXY configurate 
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =   // 240 bytes
  { 255,9,0,0,0,233,0,16,97,1,10,49,3,6,28,14,4,1,31,32,
  72,111,116,32,87,97,116,101,114,32,0,31,72,111,116,32,87,97,116,101,
  114,0,10,49,33,6,28,14,4,1,31,32,32,32,72,101,97,116,101,114,
  32,32,32,0,31,72,101,97,116,101,114,0,10,113,3,22,28,14,4,1,
  31,79,117,116,115,105,100,101,32,76,105,103,104,116,0,31,10,49,33,22,
  28,14,4,1,31,32,32,32,32,79,118,101,110,32,32,32,32,0,31,79,
  118,101,110,0,10,113,3,38,28,14,4,1,31,82,101,97,114,32,76,105,
  103,104,116,0,31,10,113,33,38,27,14,4,1,31,84,101,110,116,32,76,
  105,103,104,116,0,31,10,49,3,54,28,15,4,1,31,32,32,32,32,32,
  85,83,66,32,32,32,32,32,0,31,85,83,66,0,10,49,33,54,27,15,
  4,1,31,32,32,32,32,80,117,109,112,32,32,32,32,0,31,80,117,109,
  112,0,10,112,23,78,18,18,4,1,31,65,108,108,32,79,102,102,0,31 };
 
// this structure defines all the variables and events of your control interface
struct {

    // input variables
  uint8_t pushSwitch_1; // =1 if state is ON, else =0
  uint8_t pushSwitch_2; // =1 if state is ON, else =0
  uint8_t pushSwitch_3; // =1 if state is ON, else =0
  uint8_t pushSwitch_4; // =1 if state is ON, else =0
  uint8_t pushSwitch_5; // =1 if state is ON, else =0
  uint8_t pushSwitch_6; // =1 if state is ON, else =0
  uint8_t pushSwitch_7; // =1 if state is ON, else =0
  uint8_t pushSwitch_8; // =1 if state is ON, else =0
  uint8_t pushSwitch_9; // =1 if state is ON, else =0

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

#define PIN_PUSHSWITCH_1 5
#define PIN_PUSHSWITCH_2 6
#define PIN_PUSHSWITCH_3 7
#define PIN_PUSHSWITCH_4 8
#define PIN_PUSHSWITCH_5 9
#define PIN_PUSHSWITCH_6 10
#define PIN_PUSHSWITCH_7 11
#define PIN_PUSHSWITCH_8 12


void setup()
{
  RemoteXY_Init ();
 
  pinMode (PIN_PUSHSWITCH_1, OUTPUT);
  pinMode (PIN_PUSHSWITCH_2, OUTPUT);
  pinMode (PIN_PUSHSWITCH_3, OUTPUT);
  pinMode (PIN_PUSHSWITCH_4, OUTPUT);
  pinMode (PIN_PUSHSWITCH_5, OUTPUT);
  pinMode (PIN_PUSHSWITCH_6, OUTPUT);
  pinMode (PIN_PUSHSWITCH_7, OUTPUT);
  pinMode (PIN_PUSHSWITCH_8, OUTPUT);
 
  // TODO you setup code
 
}

void loop()
{
  RemoteXY_Handler ();
 
  digitalWrite(PIN_PUSHSWITCH_1, (RemoteXY.pushSwitch_1==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_2, (RemoteXY.pushSwitch_2==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_3, (RemoteXY.pushSwitch_3==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_4, (RemoteXY.pushSwitch_4==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_5, (RemoteXY.pushSwitch_5==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_6, (RemoteXY.pushSwitch_6==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_7, (RemoteXY.pushSwitch_7==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_8, (RemoteXY.pushSwitch_8==0)?LOW:HIGH);
 
  // TODO you loop code
  // use the RemoteXY structure for data transfer
  // do not call delay()


}

2

Re: all buttons off?

void loop()
{
  RemoteXY_Handler ();

  digitalWrite(PIN_PUSHSWITCH_1, (RemoteXY.pushSwitch_1==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_2, (RemoteXY.pushSwitch_2==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_3, (RemoteXY.pushSwitch_3==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_4, (RemoteXY.pushSwitch_4==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_5, (RemoteXY.pushSwitch_5==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_6, (RemoteXY.pushSwitch_6==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_7, (RemoteXY.pushSwitch_7==0)?LOW:HIGH);
  digitalWrite(PIN_PUSHSWITCH_8, (RemoteXY.pushSwitch_8==0)?LOW:HIGH);

   // "all-off" driven by pushswitch_9
  if(RemoteXY.pushswitch_9) {
    RemoteXY.pushswitch_1=0;
    RemoteXY.pushswitch_2=0;
    RemoteXY.pushswitch_3=0;
    RemoteXY.pushswitch_4=0;
    RemoteXY.pushswitch_5=0;
    RemoteXY.pushswitch_6=0;
    RemoteXY.pushswitch_7=0;
    RemoteXY.pushswitch_8=0;
    RemoteXY.pushswitch_9=0;
}


  // TODO you loop code
  // use the RemoteXY structure for data transfer
  // do not call delay()

}

pushswitch_9 is the "all-off" control.
Not tested, but should work ...

2B, or not 2B, that is the pencil ...