<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — LED Fading]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=565&amp;type=atom" />
	<updated>2018-09-09T15:01:52Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=565</id>
		<entry>
			<title type="html"><![CDATA[Re: LED Fading]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1787#p1787" />
			<content type="html"><![CDATA[<p>Well the code is in a loop, so it will continue looping....</p><p>the &quot;for&quot; statement starts helligkeit&nbsp; at value 1, then that is written to the ledPin.</p><p>A small delay is executed, then helligkeit is incremented by 2, and then the new value is written to the PWM pin.</p><p>This repeats itself until helligkeit increments beyond 255.</p><p>Then the code repeats itself, all over again.</p><p>If you want to control the brightness of your LED with RemoteXY, there&#039;s a couple of ways you could do it.</p><br /><p>1. Easiest way is to use a Slider control. These send a value of 0..100 to the controller, which you can then map to the 0..255 PWM pin with :-</p><div class="codebox"><pre><code>analogWrite(ledPin, (map(slider_value, 0, 100, 0, 255)));</code></pre></div><br /><p>2. Use buttons to &quot;bump&quot; the ledPin value Up and Down by a certain amount (your choice) each time the buttons are pressed.&nbsp; e.g.</p><div class="codebox"><pre><code>if (RemoteXY.buttonUp) {
 RemoteXY.buttonUp = 0;
 ledPin_value = ledPin_value + 5;
 delay(100);
}</code></pre></div><p>do the same for .buttonDown ( ledPin_value -5 ! )</p><p>then check that ledPin_value is within limits for the PWM ( 0-255 );</p><div class="codebox"><pre><code>constrain(ledPin_value, 0, 255);</code></pre></div><p>then write the value to the PWM pin.<br /></p><div class="codebox"><pre><code>analogWrite(ledPin, ledPin_value);</code></pre></div><p>You&#039;ll notice that I immediately write the button value back to zero as soon as I &quot;see&quot; it. This is to stop the button being acted on repeatedly until the RemoteXY interface resets it back to zero. Without it, you&#039;ll almost certainly get &quot;overshoot&quot;, unless that delay(100) is much, much larger.</p><p>Have fun....</p>]]></content>
			<author>
				<name><![CDATA[Daba]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=630</uri>
			</author>
			<updated>2018-09-09T15:01:52Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1787#p1787</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[LED Fading]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=1779#p1779" />
			<content type="html"><![CDATA[<p>Hi everybody,</p><p>with a control button, I would like to dim an LED:</p><p>This works without Problems:</p><p>void loop()<br />{<br />&nbsp; for (int helligkeit =1; helligkeit &lt;= 255; helligkeit = helligkeit +2)<br />&nbsp; {<br />&nbsp; &nbsp; analogWrite(ledPin, helligkeit);<br />&nbsp; &nbsp; delay(10);<br />&nbsp; }</p><p>But, as soon as I initiate this routine by a Remotexy button, it seems, a loop is processed (LED is dimmed down to 0, then starts again from the beginning). Does somebody has any idea?</p><p>Thanks!!!!</p>]]></content>
			<author>
				<name><![CDATA[testapps]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=704</uri>
			</author>
			<updated>2018-09-03T15:01:39Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=1779#p1779</id>
		</entry>
</feed>
