<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — Local switch error]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1074&amp;type=atom" />
	<updated>2020-07-04T21:36:51Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=1074</id>
		<entry>
			<title type="html"><![CDATA[Re: Local switch error]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3126#p3126" />
			<content type="html"><![CDATA[<p>Welcome,</p><p>Your code makes no sense</p><div class="codebox"><pre><code>if(digitalRead(PIN_SWITCH_1==HIGH)){</code></pre></div><p>PIN_SWITCH_1 == HIGH ? No, PIN_SWITCH_1 == D0</p><p>You probably want to do this instead:<br /></p><div class="codebox"><pre><code>if(digitalRead(PIN_SWITCH_1)==HIGH){</code></pre></div><p>But there is another logic problem, you have set PIN_SWITCH_1 to be an output, so what are you trying to read from it ?</p>]]></content>
			<author>
				<name><![CDATA[Guillaume]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=23</uri>
			</author>
			<updated>2020-07-04T21:36:51Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3126#p3126</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Local switch error]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3121#p3121" />
			<content type="html"><![CDATA[<p>Dear friends!</p><p>I expect local switches and apps the switches work synchronously,<br />but I don’t know where the error is, it failed, !!!</p><p>Can someone with high ability help? Thank you!</p><br /><p>#define REMOTEXY_MODE__ESP8266WIFI_LIB_CLOUD<br />#include &lt;ESP8266WiFi.h&gt;</p><p>#include &lt;RemoteXY.h&gt;</p><p>// RemoteXY connection settings <br />#define REMOTEXY_WIFI_SSID &quot;WR2&quot;<br />#define REMOTEXY_WIFI_PASSWORD &quot;edcbafde36&quot;<br />#define REMOTEXY_CLOUD_SERVER &quot;cloud.remotexy.com&quot;<br />#define REMOTEXY_CLOUD_PORT 6376<br />#define REMOTEXY_CLOUD_TOKEN &quot;1f3898d89cd3eee63ee639a077ad58ea&quot;<br />int DD6=0;<br />int DD7=0;<br />int DD8=0;</p><p>// RemoteXY configurate&nbsp; <br />#pragma pack(push, 1)<br />uint8_t RemoteXY_CONF[] =<br />&nbsp; { 255,6,0,0,0,252,0,10,13,1,<br />&nbsp; 2,1,37,18,20,8,2,26,31,31,<br />&nbsp; 79,78,0,79,70,70,0,2,1,37,<br />&nbsp; 32,20,8,2,26,31,31,79,78,0,<br />&nbsp; 79,70,70,0,2,1,36,47,21,8,<br />&nbsp; 2,26,31,31,79,78,0,79,70,70,<br />&nbsp; 0,2,1,36,62,21,8,2,26,31,<br />&nbsp; 31,79,78,0,79,70,70,0,2,1,<br />&nbsp; 36,77,21,8,2,26,31,31,79,78,<br />&nbsp; 0,79,70,70,0,2,1,36,91,21,<br />&nbsp; 9,2,26,31,31,79,78,0,79,70,<br />&nbsp; 70,0,129,0,5,19,28,5,17,82,<br />&nbsp; 101,108,97,121,32,48,49,32,45,45,<br />&nbsp; 45,45,0,129,0,5,34,28,5,17,<br />&nbsp; 82,101,108,97,121,32,48,50,32,45,<br />&nbsp; 45,45,45,0,129,0,5,49,20,5,<br />&nbsp; 17,82,101,108,97,121,32,48,51,32,<br />&nbsp; 45,45,45,45,0,129,0,5,63,28,<br />&nbsp; 5,17,82,101,108,97,121,32,48,52,<br />&nbsp; 32,45,45,45,45,0,129,0,4,78,<br />&nbsp; 20,5,17,82,101,108,97,121,32,48,<br />&nbsp; 53,32,45,45,45,45,0,129,0,4,<br />&nbsp; 92,28,5,17,82,101,108,97,121,32,<br />&nbsp; 48,54,32,45,45,45,45,0,129,0,<br />&nbsp; 4,0,54,8,15,83,105,120,32,82,<br />&nbsp; 101,108,97,121,32,83,89,83,0 };<br />&nbsp; <br />// this structure defines all the variables and events of your control interface <br />struct {</p><p>&nbsp; &nbsp; // input variables<br />&nbsp; uint8_t switch_1; // =1 if switch ON and =0 if OFF <br />&nbsp; uint8_t switch_2; // =1 if switch ON and =0 if OFF <br />&nbsp; uint8_t switch_3; // =1 if switch ON and =0 if OFF <br />&nbsp; uint8_t switch_4; // =1 if switch ON and =0 if OFF <br />&nbsp; uint8_t switch_5; // =1 if switch ON and =0 if OFF <br />&nbsp; uint8_t switch_6; // =1 if switch ON and =0 if OFF </p><p>&nbsp; &nbsp; // other variable<br />&nbsp; uint8_t connect_flag;&nbsp; // =1 if wire connected, else =0 </p><p>} RemoteXY;<br />#pragma pack(pop)</p><p>/////////////////////////////////////////////<br />//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END RemoteXY include&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />/////////////////////////////////////////////</p><p>#define PIN_SWITCH_1 D0<br />#define PIN_SWITCH_2 D1<br />#define PIN_SWITCH_3 D2<br />#define PIN_SWITCH_4 D3<br />#define PIN_SWITCH_5 D4<br />#define PIN_SWITCH_6 D5<br />/*<br />#define PIN_IN_6 D6<br />#define PIN_IN_7 D7<br />#define PIN_IN_8 D8<br />*/<br />void setup() <br />{<br />&nbsp; RemoteXY_Init (); <br />&nbsp; <br />&nbsp; pinMode (PIN_SWITCH_1, OUTPUT);<br />&nbsp; pinMode (PIN_SWITCH_2, OUTPUT);<br />&nbsp; pinMode (PIN_SWITCH_3, OUTPUT);<br />&nbsp; pinMode (PIN_SWITCH_4, OUTPUT);<br />&nbsp; pinMode (PIN_SWITCH_5, OUTPUT);<br />&nbsp; pinMode (PIN_SWITCH_6, OUTPUT);<br />&nbsp; pinMode (D6, INPUT);<br />&nbsp; pinMode (D7, INPUT);<br />&nbsp; pinMode (D8, INPUT);<br />&nbsp; <br />&nbsp; // TODO you setup code<br />&nbsp; <br />}</p><p>void loop() { <br />&nbsp; RemoteXY_Handler ();<br />&nbsp; digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);<br />&nbsp; digitalWrite(PIN_SWITCH_2, (RemoteXY.switch_2==0)?LOW:HIGH);<br />&nbsp; digitalWrite(PIN_SWITCH_3, (RemoteXY.switch_3==0)?LOW:HIGH);<br />&nbsp; digitalWrite(PIN_SWITCH_4, (RemoteXY.switch_4==0)?LOW:HIGH);<br />&nbsp; digitalWrite(PIN_SWITCH_5, (RemoteXY.switch_5==0)?LOW:HIGH);<br />&nbsp; digitalWrite(PIN_SWITCH_6, (RemoteXY.switch_6==0)?LOW:HIGH);<br />&nbsp; <br />DD6=digitalRead(D6);<br />DD7=digitalRead(D7);<br />DD8=digitalRead(D8);</p><p>&nbsp; if(DD6 == HIGH){<br />&nbsp; &nbsp; if(digitalRead(PIN_SWITCH_1==HIGH)){ digitalWrite(PIN_SWITCH_1,LOW);&nbsp; &nbsp; }<br />&nbsp; &nbsp; else if(digitalRead(PIN_SWITCH_1==LOW)){ digitalWrite(PIN_SWITCH_1,HIGH);&nbsp; &nbsp; }}<br />&nbsp; else if(DD7 == HIGH){<br />&nbsp; &nbsp; if(digitalRead(PIN_SWITCH_2==HIGH)){ digitalWrite(PIN_SWITCH_2,LOW);&nbsp; &nbsp; }<br />&nbsp; &nbsp; else if(digitalRead(PIN_SWITCH_2==LOW)){ digitalWrite(PIN_SWITCH_2,HIGH);&nbsp; &nbsp; }}<br />&nbsp; else if(DD8 == HIGH){<br />&nbsp; &nbsp; if(digitalRead(PIN_SWITCH_3==HIGH)){ digitalWrite(PIN_SWITCH_3,LOW);&nbsp; &nbsp; }<br />&nbsp; &nbsp; else if(digitalRead(PIN_SWITCH_3==LOW)){ digitalWrite(PIN_SWITCH_3,HIGH);&nbsp; &nbsp; }}<br /> else{}<br />&nbsp; // TODO you loop code<br />&nbsp; // use the RemoteXY structure for data transfer<br />&nbsp; // do not call delay() <br />}</p>]]></content>
			<author>
				<name><![CDATA[ivanTang]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1433</uri>
			</author>
			<updated>2020-07-04T05:28:42Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3121#p3121</id>
		</entry>
</feed>
