<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — Add delay to button control]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1191&amp;type=atom" />
	<updated>2020-10-18T22:51:34Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=1191</id>
		<entry>
			<title type="html"><![CDATA[Re: Add delay to button control]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3421#p3421" />
			<content type="html"><![CDATA[<p>Welcome,</p><p>Try something like this<br /></p><div class="codebox"><pre><code>void loop()
{
  RemoteXY_Handler ();

  uint32_t now = millis();
  static bool buttonWasPressed = false;
  static uint32_t buttonMillis = now;

  if ( RemoteXY.Unlock_Door == 1 )
  {
    buttonWasPressed = true;
    buttonMillis = now;
    digitalWrite(PIN_UNLOCK_DOOR, HIGH);
  }

  if ( buttonWasPressed &amp;&amp; now - buttonMillis &gt;= 3000UL )
  {
    buttonWasPressed = false;
    digitalWrite(PIN_UNLOCK_DOOR, LOW);
  }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Guillaume]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=23</uri>
			</author>
			<updated>2020-10-18T22:51:34Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3421#p3421</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Add delay to button control]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3417#p3417" />
			<content type="html"><![CDATA[<p>Heloo everyone, Im a new remotexy user here. I need some help here.</p><p>Im using Arduino Uno and Esp 8266 Wifi Module to control a relay that is connected to a solenoid door lock.</p><p>Just wondering how can i add a delay to the button control on the smartphone that the button stay on high (Unlock Door) 3 seconds before going to low(Lock Door) again.<br />TQ <img src="https://forum.remotexy.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>My Code:</p><p>/*<br />&nbsp; &nbsp;-- New project --<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;This source code of graphical user interface <br />&nbsp; &nbsp;has been generated automatically by RemoteXY editor.<br />&nbsp; &nbsp;To compile this code using RemoteXY library 2.4.3 or later version <br />&nbsp; &nbsp;download by link <a target="_blank" href="http://remotexy.com/en/library/">http://remotexy.com/en/library/</a><br />&nbsp; &nbsp;To connect using RemoteXY mobile app by link <a target="_blank" href="http://remotexy.com/en/download/">http://remotexy.com/en/download/</a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp;- for ANDROID 4.5.1 or later version;<br />&nbsp; &nbsp; &nbsp;- for iOS 1.4.1 or later version;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp;This source code is free software; you can redistribute it and/or<br />&nbsp; &nbsp;modify it under the terms of the GNU Lesser General Public<br />&nbsp; &nbsp;License as published by the Free Software Foundation; either<br />&nbsp; &nbsp;version 2.1 of the License, or (at your option) any later version.&nbsp; &nbsp; <br />*/</p><p>//////////////////////////////////////////////<br />//&nbsp; &nbsp; &nbsp; &nbsp; RemoteXY include library&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />//////////////////////////////////////////////</p><p>// RemoteXY select connection mode and include library <br />#define REMOTEXY_MODE__ESP8266_HARDSERIAL_POINT</p><p>#include &lt;RemoteXY.h&gt;</p><p>// RemoteXY connection settings <br />#define REMOTEXY_SERIAL Serial<br />#define REMOTEXY_SERIAL_SPEED 115200<br />#define REMOTEXY_WIFI_SSID &quot;RemoteXY&quot;<br />#define REMOTEXY_WIFI_PASSWORD &quot;12345678&quot;<br />#define REMOTEXY_SERVER_PORT 6377</p><br /><p>// RemoteXY configurate&nbsp; <br />#pragma pack(push, 1)<br />uint8_t RemoteXY_CONF[] =<br />&nbsp; { 255,1,0,0,0,13,0,10,13,1,<br />&nbsp; 1,0,20,37,21,21,2,31,88,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 Unlock_Door; // =1 if button pressed, else =0 </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_UNLOCK_DOOR 2</p><br /><p>void setup() <br />{<br />&nbsp; RemoteXY_Init (); <br />&nbsp; <br />&nbsp; pinMode (PIN_UNLOCK_DOOR, OUTPUT);<br />&nbsp; <br />&nbsp; // TODO you setup code<br />&nbsp; <br />}</p><p>void loop() <br />{ <br />&nbsp; RemoteXY_Handler ();<br />&nbsp; <br />&nbsp; digitalWrite(PIN_UNLOCK_DOOR, (RemoteXY.Unlock_Door==0)?LOW:HIGH);<br />&nbsp; <br />&nbsp; // TODO you loop code<br />&nbsp; // use the RemoteXY structure for data transfer<br />&nbsp; // do not call delay() </p><br /><p>}</p>]]></content>
			<author>
				<name><![CDATA[ezamlol]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1588</uri>
			</author>
			<updated>2020-10-18T11:13:53Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3417#p3417</id>
		</entry>
</feed>
