<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — Input / Output Array]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=417&amp;type=atom" />
	<updated>2018-03-16T23:14:12Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=417</id>
		<entry>
			<title type="html"><![CDATA[Re: Input / Output Array]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1415#p1415" />
			<content type="html"><![CDATA[<p>Ok, i Will try! <img src="https://forum.remotexy.com/img/smilies/smile.png" width="15" height="15" alt="smile" /> </p><p>Ty!!</p>]]></content>
			<author>
				<name><![CDATA[saddys]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=586</uri>
			</author>
			<updated>2018-03-16T23:14:12Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1415#p1415</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Input / Output Array]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1414#p1414" />
			<content type="html"><![CDATA[<p>Good <img src="https://forum.remotexy.com/img/smilies/wink.png" width="15" height="15" alt="wink" /></p><p>You can solve these warnings by doing this:<br /></p><div class="codebox"><pre><code>uint8_t RemoteXY_CONF[] = 
  { 255,4,0,69,0,22,1,8,13,2,
  130,1,24,0,25,45,0,(uint8_t)-1,25,45,</code></pre></div><br /><p>You could put your sensors in an array too</p><div class="codebox"><pre><code>DHT_nonblocking dhtSensors[] = 
{
  DHT_nonblocking( 2, DHT_TYPE_11 ),
  DHT_nonblocking( 3, DHT_TYPE_11 ),
  DHT_nonblocking( 4, DHT_TYPE_11 ),
};</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Guillaume]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=23</uri>
			</author>
			<updated>2018-03-16T21:13:18Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1414#p1414</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Input / Output Array]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1413#p1413" />
			<content type="html"><![CDATA[<p>Uh!! The problem was simply due to the fact that a graphic panel started just outside the screen <img src="https://forum.remotexy.com/img/smilies/tongue.png" width="15" height="15" alt="tongue" /></p>]]></content>
			<author>
				<name><![CDATA[saddys]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=586</uri>
			</author>
			<updated>2018-03-16T15:39:38Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1413#p1413</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Input / Output Array]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1412#p1412" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Guillaume wrote:</cite><blockquote><p>I think you don&#039;t want to do this:<br />You probaby want to do this instead:<br /></p><div class="codebox"><pre><code>readingRemote[i] = *buttRemote[i];</code></pre></div><p>Good luck <img src="https://forum.remotexy.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p></blockquote></div><p>Wow, all perfect!! <img src="https://forum.remotexy.com/img/smilies/smile.png" width="15" height="15" alt="smile" /> ty very much</p><p>Do not laugh please!!!!</p><p>This is my sketch (remember that i&#039;m newbie <img src="https://forum.remotexy.com/img/smilies/tongue.png" width="15" height="15" alt="tongue" />)</p><p>Surely it&#039;s badly badly written, but everything works <img src="https://forum.remotexy.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>Relays, buttons, all relays off, 3 temperature probes even from the app (I used DHT_noblocking because with the standard one I had annoying delays on buttons/led)</p><p>I have this error during compiling but all is ok.. do you know why? it report the last string of RemoteXY configurate (4,6,133,72,0 }; but I have only copied from editor source code)</p><div class="codebox"><pre><code>C:\Users\user\Documents\Arduino\app.ino:51:16: warning: narrowing conversion of &#039;-1&#039; from &#039;int&#039; to &#039;const uint8_t {aka const unsigned char}&#039; inside { } [-Wnarrowing]

   4,6,133,72,0 };  

                ^
C:\Users\user\Documents\Arduino\app.ino:51:16: warning: narrowing conversion of &#039;-1&#039; from &#039;int&#039; to &#039;const uint8_t {aka const unsigned char}&#039; inside { } [-Wnarrowing]</code></pre></div><p>By the way, this is the code</p><div class="codebox"><pre><code>///////////////////////////////////////////// 
//        RemoteXY include library         // 
///////////////////////////////////////////// 

/* RemoteXY select connection mode and include library */ 
#define REMOTEXY_MODE__ETHERNET_LIB
#include &lt;Ethernet.h&gt;
#include &lt;SPI.h&gt;
#include &lt;RemoteXY.h&gt;
#include &lt;dht_nonblocking.h&gt;
//#include &lt;DHT.h&gt;
//#include &lt;DHT_U.h&gt;
#include &lt;Adafruit_Sensor.h&gt;

/* RemoteXY connection settings */
#define REMOTEXY_ETHERNET_MAC &quot;DE:AD:BE:EF:EF:ED&quot;
#define REMOTEXY_SERVER_PORT 6377

// RemoteXY configurate   
#pragma pack(push, 1) 
uint8_t RemoteXY_CONF[] = 
  { 255,4,0,69,0,22,1,8,13,2,
  130,1,24,0,25,45,0,-1,25,45,
  17,130,1,49,0,25,45,25,0,25,
  44,17,130,1,-1,0,25,45,0,47,
  25,43,17,1,0,7,2,12,12,6,
  3,12,12,2,31,88,0,1,0,30,
  3,12,12,30,3,12,12,2,31,88,
  0,1,0,54,3,12,12,6,50,12,
  12,2,31,88,0,65,2,8,16,9,
  9,8,17,9,9,65,2,31,17,9,
  9,32,17,9,9,65,2,56,17,9,
  9,7,64,9,9,1,0,84,16,12,
  12,34,62,12,12,2,31,88,0,67,
  4,8,32,13,4,7,27,18,5,2,
  26,11,67,4,33,32,13,4,32,27,
  17,5,2,26,11,67,4,59,32,13,
  4,7,76,18,5,2,26,11,67,4,
  8,39,13,4,7,32,18,5,2,26,
  11,67,4,33,39,13,4,32,32,17,
  5,2,26,11,67,4,59,39,13,4,
  7,81,18,5,2,26,11,129,0,1,
  31,6,6,1,27,18,6,133,84,0,
  129,0,1,38,10,6,1,32,6,6,
  133,72,0,129,0,26,31,4,6,26,
  27,4,6,133,84,0,129,0,51,31,
  4,6,1,75,4,6,133,84,0,129,
  0,51,38,4,6,26,32,4,6,133,
  72,0,129,0,26,38,4,6,1,80,
  4,6,133,72,0 };  
   
// this structure defines all the variables of your control interface  
struct { 

    // input variable
  uint8_t button_1; // =1 if button pressed, else =0 
  uint8_t button_2; // =1 if button pressed, else =0 
  uint8_t button_3; // =1 if button pressed, else =0 
  uint8_t button_ALL; // =1 if button pressed, else =0 

    // output variable
  uint8_t led_1_g; // =0..255 LED Red brightness 
  uint8_t led_2_g; // =0..255 LED Red brightness 
  uint8_t led_3_g; // =0..255 LED Red brightness 
  char text_temp1[11];  // string UTF8 end zero 
  char text_temp2[11];  // string UTF8 end zero 
  char text_temp3[11];  // string UTF8 end zero 
  char text_hum1[11];  // string UTF8 end zero 
  char text_hum2[11];  // string UTF8 end zero 
  char text_hum3[11];  // string UTF8 end zero
   
    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY; 

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

#define DHT_SENSOR_TYPE DHT_TYPE_11
static const int DHT_SENSOR_PIN2 = 2;
DHT_nonblocking dht_sensor1( DHT_SENSOR_PIN2, DHT_SENSOR_TYPE );
static const int DHT_SENSOR_PIN3 = 3;
DHT_nonblocking dht_sensor2( DHT_SENSOR_PIN3, DHT_SENSOR_TYPE );
static const int DHT_SENSOR_PIN4 = 4;
DHT_nonblocking dht_sensor3( DHT_SENSOR_PIN4, DHT_SENSOR_TYPE );

#define buttPinALL 34          // pin pulsante SPEGNI TUTTO
int buttPin[3] = {27,28,29};   // arrow for real switch button 
int relayPin[3] = {30,31,32};  // arrow for real output relay
uint8_t * buttRemoteALL = &amp;RemoteXY.button_ALL;
uint8_t * buttRemote[3] = {&amp;RemoteXY.button_1,&amp;RemoteXY.button_2,&amp;RemoteXY.button_3};
uint8_t * ledRemote[3] = {&amp;RemoteXY.led_1_g, &amp;RemoteXY.led_2_g, &amp;RemoteXY.led_3_g};

int reading[3];
int readingButtALL;
int readingRemote[3];
int readingRemoteALL;

int buttState[3];
int buttStateALL;
int buttRemoteState[3];
int buttRemoteStateALL;

int lastButtState[3];
int lastButtStateALL;
int lastButtRemoteState[3];
int lastButtRemoteStateALL;


int debounceDelay = 50;

int ledState[3];

unsigned long lastDebounceTime[3];
unsigned long lastDebounceTimeALL;


void setup()  
{ 
  RemoteXY_Init ();  
{
  Serial.begin( 115200 );
}

  for (int i = 0; i &lt; 3; i++)
  { pinMode(relayPin[i], OUTPUT);
    pinMode(buttPin[i], INPUT_PULLUP);}
    pinMode(buttPinALL, INPUT_PULLUP);
}  

static bool measure_environment1( float *temperature1, float *humidity1 )
 { static unsigned long measurement_timestamp1 = millis( );
   if( millis( ) - measurement_timestamp1 &gt; 4000ul ) /* Measure once every four seconds. */
   { if( dht_sensor1.measure( temperature1, humidity1 ) == true )
      { measurement_timestamp1 = millis( );
        return( true ); }
      } return( false );}

static bool measure_environment2( float *temperature2, float *humidity2 )
 { static unsigned long measurement_timestamp2 = millis( );
   if( millis( ) - measurement_timestamp2 &gt; 4000ul ) /* Measure once every four seconds. */
   { if( dht_sensor2.measure( temperature2, humidity2 ) == true )
      { measurement_timestamp2 = millis( );
        return( true ); }
      } return( false );}
  
static bool measure_environment3( float *temperature3, float *humidity3 )
 { static unsigned long measurement_timestamp3 = millis( );
  if( millis( ) - measurement_timestamp3 &gt; 4000ul ) /* Measure once every four seconds. */
    { if( dht_sensor3.measure( temperature3, humidity3 ) == true )
      { measurement_timestamp3 = millis( );
        return( true ); }
      } return( false );}

void loop()  
{ RemoteXY_Handler (); 
     
for (int i = 0; i &lt; 3; i++) //lettura pulsanti fisici
    { reading[i] = digitalRead(buttPin[i]);
      if (reading[i] != lastButtState[i]) {
         lastDebounceTime[i] = millis(); 
         lastButtState[i] = reading[i]; }
      if ((millis() - lastDebounceTime[i]) &gt; debounceDelay) {
          if (buttState[i] != lastButtState[i]) {
          buttState[i] = lastButtState[i];
             if (buttState[i] == LOW) {
             ledState[i] = !ledState[i];
             digitalWrite(relayPin[i], ledState[i]); }}}}

for (int i = 0; i &lt; 3; i++) //lettura pulsanti da app remota
    { readingRemote[i] = *buttRemote[i];
      if (readingRemote[i] != lastButtRemoteState[i]) {
         lastDebounceTime[i] = millis(); 
         lastButtRemoteState[i] = readingRemote[i]; }
      if ((millis() - lastDebounceTime[i]) &gt; debounceDelay) {
         if (buttRemoteState[i] != lastButtRemoteState[i]) {
         buttRemoteState[i] = lastButtRemoteState[i];
            if (buttRemoteState[i] == HIGH) {
            ledState[i] = !ledState[i];
            digitalWrite(relayPin[i], ledState[i]);}}}}

      readingButtALL = digitalRead(buttPinALL); // SWITCH OFF da pulsante fisico
      if (readingButtALL != lastButtStateALL) {
         lastDebounceTimeALL = millis(); 
         lastButtStateALL = readingButtALL; }
      if ((millis() - lastDebounceTimeALL) &gt; debounceDelay) {
         if (buttStateALL != lastButtStateALL) {
             buttStateALL = lastButtStateALL;
         if (buttStateALL == LOW) {
            ledState[0] = LOW;
            ledState[1] = LOW;
            ledState[2] = LOW;
            digitalWrite(30, LOW);
            digitalWrite(31, LOW);
            digitalWrite(32, LOW);}}}

      readingRemoteALL = *buttRemoteALL; // SWITCH OFF da pulsante APP
      if (readingRemoteALL != lastButtRemoteStateALL) {
         lastDebounceTimeALL = millis(); 
         lastButtRemoteStateALL = readingRemoteALL; }
      if ((millis() - lastDebounceTimeALL) &gt; debounceDelay) {
         if (buttRemoteStateALL != lastButtRemoteStateALL) {
             buttRemoteStateALL = lastButtRemoteStateALL;
         if (buttRemoteStateALL == HIGH) {
            ledState[0] = LOW;
            ledState[1] = LOW;
            ledState[2] = LOW;
            digitalWrite(30, LOW);
            digitalWrite(31, LOW);
            digitalWrite(32, LOW);}}}           

            
for (int i = 0; i &lt; 3; i++) // accendi/spegni led su app
   { *ledRemote[i] = (digitalRead(relayPin[i])==HIGH)?255:0; }

// lettura delle temperature

{ float temperature1;
  float humidity1;
  if( measure_environment1( &amp;temperature1, &amp;humidity1 ) == true )
  { dtostrf(temperature1, 0, 1, RemoteXY.text_temp1);
    dtostrf(humidity1, 0, 1, RemoteXY.text_hum1); } }

{ float temperature2;
  float humidity2;
  if( measure_environment2( &amp;temperature2, &amp;humidity2 ) == true )
  { dtostrf(temperature2, 0, 1, RemoteXY.text_temp2);
    dtostrf(humidity2, 0, 1, RemoteXY.text_hum2); } }

{ float temperature3;
  float humidity3;
  if( measure_environment3( &amp;temperature3, &amp;humidity3 ) == true )
  { dtostrf(temperature3, 0, 1, RemoteXY.text_temp3);
    dtostrf(humidity3, 0, 1, RemoteXY.text_hum3); } }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[saddys]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=586</uri>
			</author>
			<updated>2018-03-16T14:53:31Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1412#p1412</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Input / Output Array]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1410#p1410" />
			<content type="html"><![CDATA[<p>I think you don&#039;t want to do this:<br /></p><div class="codebox"><pre><code>readingRemote[i] = digitalRead( *buttRemote[i] );</code></pre></div><p>You probaby want to do this instead:<br /></p><div class="codebox"><pre><code>readingRemote[i] = *buttRemote[i];</code></pre></div><p>In fact you may not need this line at all.</p><p>Good luck <img src="https://forum.remotexy.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[Guillaume]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=23</uri>
			</author>
			<updated>2018-03-16T00:17:00Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1410#p1410</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Input / Output Array]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1409#p1409" />
			<content type="html"><![CDATA[<p>Thanks! </p><p>Tomorrow I will play with your code <img src="https://forum.remotexy.com/img/smilies/smile.png" width="15" height="15" alt="smile" /> </p><p>My struct/code (now) is for understand the mechanism, i&#039;m new in this world! </p><p>I wan&#039;t to implement at the end:</p><p>15 button+15relay for light room and 1 button for &quot;ALL LIGHT OFF&quot;<br />2 or 3 RGB control for strip rgb led<br />5 dht sensor</p><p>And finally the impossibile thing: 6 window&#039;s motor</p><p><img src="https://forum.remotexy.com/img/smilies/tongue.png" width="15" height="15" alt="tongue" /></p><p>For now I want learn and understand simply code... For me, now, the sketch of first post with array code is my current goal! </p><p>I started this Monday to go into this world, and my first sketch was a code repeated 20 times <img src="https://forum.remotexy.com/img/smilies/wink.png" width="15" height="15" alt="wink" /> Today I studied (with forum examples) and tried to use arrays with success and the code has been greatly reduced! I&#039;m very happy! </p><p>Slowly I will apply myself to insert the other things written above ... In the limit I will disturb you in exchange for a pizza and a beer (or more beers and pizzas) if you want/can <img src="https://forum.remotexy.com/img/smilies/wink.png" width="15" height="15" alt="wink" />&nbsp; ;p</p>]]></content>
			<author>
				<name><![CDATA[saddys]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=586</uri>
			</author>
			<updated>2018-03-15T22:56:38Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1409#p1409</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Input / Output Array]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1407#p1407" />
			<content type="html"><![CDATA[<p>NP <img src="https://forum.remotexy.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>By the way, if (and only if) your struct really look like in your first post, then you don&#039;t need to do all that, you can just replace your struct by:</p><div class="codebox"><pre><code>struct { 

    // input variable
  uint8_t buttons[3]; // =1 if button pressed, else =0 

    // output variable
  uint8_t leds[3]; // =0..255 LED Red brightness 

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

} RemoteXY;</code></pre></div><p>Also something that you might find useful, it&#039;s outdated but still relevant : <a target="_blank" href="http://forum.remotexy.com/viewtopic.php?id=120">http://forum.remotexy.com/viewtopic.php?id=120</a></p>]]></content>
			<author>
				<name><![CDATA[Guillaume]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=23</uri>
			</author>
			<updated>2018-03-15T20:57:08Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1407#p1407</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Input / Output Array]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1406#p1406" />
			<content type="html"><![CDATA[<p>You are my favorite genius</p><p>Tomorrow I tell you if all ok <img src="https://forum.remotexy.com/img/smilies/smile.png" width="15" height="15" alt="smile" /> </p><p>Thank you so much, very kind</p>]]></content>
			<author>
				<name><![CDATA[saddys]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=586</uri>
			</author>
			<updated>2018-03-15T20:49:22Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1406#p1406</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Input / Output Array]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1405#p1405" />
			<content type="html"><![CDATA[<p>Use<br /></p><div class="codebox"><pre><code>digitalRead( *buttRemote[i] );</code></pre></div><p>Because you want to get the value at the pointed address, not the address itself.</p><p>And I don&#039;t see why you couldn&#039;t use logical or <img src="https://forum.remotexy.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>I modified my previous post to change the type of the pointer to uint8_t (because those led_r variables are uint8_t so the pointers should be of the same type).</p>]]></content>
			<author>
				<name><![CDATA[Guillaume]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=23</uri>
			</author>
			<updated>2018-03-15T20:44:12Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1405#p1405</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Input / Output Array]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1404#p1404" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Guillaume wrote:</cite><blockquote><p>Welcome ;) You need to store pointers to those variables.</p></blockquote></div><p>Uh, thanks, tomorrow i&#039;ll try... So, i can define in this way </p><div class="codebox"><pre><code>int * ledRemote[3] = {&amp;Remotexy.button_1,&amp;RemoteXY.button_2,&amp;RemoteXY.button_3};
int * buttRemote[3] = {&amp;RemoteXY.led_1_r,&amp;RemoteXY.led_2_r,&amp;RemoteXY.led_3_r };  </code></pre></div><p>And in for (int i) i can use this:</p><div class="codebox"><pre><code>for (int i = 0; i &lt; 3; i++) 
 {
reading[i] = digitalRead(buttPin[i]);
readingRemote[i] = digitalRead(buttRemote[i]);
if (reading[i] != lastButtState[i] || readingRemote[i] != lastButtState[i]) { </code></pre></div><p>Can i use logical OR in this case? </p><p>Ty very much Guillaume!</p>]]></content>
			<author>
				<name><![CDATA[saddys]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=586</uri>
			</author>
			<updated>2018-03-15T19:07:46Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1404#p1404</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Input / Output Array]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1398#p1398" />
			<content type="html"><![CDATA[<p>Welcome <img src="https://forum.remotexy.com/img/smilies/wink.png" width="15" height="15" alt="wink" /></p><p>You need to store pointers to those variables. For example:<br /></p><div class="codebox"><pre><code>uint8_t * ledRemote[3] = { &amp;RemoteXY.led_1_r, &amp;RemoteXY.led_2_r, &amp;RemoteXY.led_3_r };</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Guillaume]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=23</uri>
			</author>
			<updated>2018-03-15T16:45:50Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1398#p1398</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Input / Output Array]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1397#p1397" />
			<content type="html"><![CDATA[<p>Hi!</p><p>I want to know if is possible to use app input and output (RemoteXY.button or .led) in an Array.</p><p>I try but unsuccesfully. The physics button and phisics LED are OK (switch ON with one press of button and OFF with another press of button and ON/OFF the corresponding led).</p><p>Can someone help me please for the remotexy code?</p><p>thanks</p><div class="codebox"><pre><code>///////////////////////////////////////////// 
//        RemoteXY include library         // 
///////////////////////////////////////////// 

/* RemoteXY select connection mode and include library */ 
#define REMOTEXY_MODE__ETHERNET_LIB
#include &lt;Ethernet.h&gt;
#include &lt;SPI.h&gt;

#include &lt;RemoteXY.h&gt;

/* RemoteXY connection settings */
#define REMOTEXY_ETHERNET_MAC &quot;DE:AD:BE:EF:EF:ED&quot;
#define REMOTEXY_SERVER_PORT 6377

// RemoteXY configurate   
#pragma pack(push, 1) 
uint8_t RemoteXY_CONF[] = 
  { 255,3,0,3,0,51,0,8,13,0,
  1,0,12,12,12,12,2,31,88,0,
  1,0,31,12,12,12,2,31,88,0,
  1,0,75,14,12,12,2,31,88,0,
  65,4,13,29,9,9,65,4,33,29,
  9,9,65,4,77,28,9,9 }; 
   
// this structure defines all the variables of your control interface  
struct { 

    // input variable
  uint8_t button_1; // =1 if button pressed, else =0 
  uint8_t button_2; // =1 if button pressed, else =0 
  uint8_t button_3; // =1 if button pressed, else =0 

    // output variable
  uint8_t led_1_r; // =0..255 LED Red brightness 
  uint8_t led_2_r; // =0..255 LED Red brightness 
  uint8_t led_3_r; // =0..255 LED Red brightness 

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

} RemoteXY; 

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

int buttPin[3] = {27,28,29};   // arrow for real switch button 
int relayPin[3] = {30,31,32};  // arrow for real output relay
int buttRemote[3] = {RemoteXY.button_1,RemoteXY.button_2,RemoteXY.button_3}; //IS OK TO PUT THEM IN AN ARROW?
int ledRemote[3] = {RemoteXY.led_1_r,RemoteXY.led_2_r,RemoteXY.led_3_r};     //IS OK TO PUT THEM IN AN ARROW?
int lastButtState[3];
int buttState[3];
int debounceDelay = 50;
int ledState[3];
int reading[3];
int readingRemote[3];
unsigned long lastDebounceTime[3];


void setup()  
{ 
  RemoteXY_Init ();  
  for (int i = 0; i &lt; 3; i++)
  {
    pinMode(relayPin[i], OUTPUT);
    pinMode(buttPin[i], INPUT_PULLUP); 
  }
}  


void loop()  
{  
  RemoteXY_Handler (); 

     
for (int i = 0; i &lt; 3; i++) // I USE ARRAY BECAUSE I NEED IN THE FUTURE 16 INPUT/RELAYS TO USE
  {
    reading[i] = digitalRead(buttPin[i]);
//    readingRemote[i] = digitalRead(buttRemote[i]);
    if (reading[i] != lastButtState[i]) {
    //  if (reading[i] != lastButtState[i] || readingRemote[i] != lastButtState[i]) { // I NEED SWITCH ON or OFF with a change of phisic button or APP button
      lastDebounceTime[i] = millis(); // for don&#039;t use DELAY functions i USE millis
      lastButtState[i] = reading[i];
        
                                        }
    if ((millis() - lastDebounceTime[i]) &gt; debounceDelay) {
       if (buttState[i] != lastButtState[i]) {
           buttState[i] = lastButtState[i];
           if (buttState[i] == HIGH) {
                 ledState[i] = !ledState[i];
                 digitalWrite(relayPin[i], ledState[i]);
                                                
                                     }
                 RemoteXY.led_1_r = (digitalRead(30)==HIGH)?255:0; // with a defined (ledRemote[i]) ARRAY i can&#039;t monitoring the led if I put it in for loop, so i use here succesfully
                 RemoteXY.led_2_r = (digitalRead(31)==HIGH)?255:0; // with a defined (ledRemote[i]) ARRAY i can&#039;t monitoring the led if I put it in for loop, so i use here succesfully
                 RemoteXY.led_3_r = (digitalRead(32)==HIGH)?255:0; // with a defined (ledRemote[i]) ARRAY i can&#039;t monitoring the led if I put it in for loop, so i use here succesfully
                       
                                            }
                                                          }
  }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[saddys]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=586</uri>
			</author>
			<updated>2018-03-15T13:52:15Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1397#p1397</id>
		</entry>
</feed>
