<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>Using a single button as a on/off switch</title>
		<link>http://aseba.wikidot.com/forum/t-1035096/using-a-single-button-as-a-on-off-switch</link>
		<description>Posts in the discussion thread &quot;Using a single button as a on/off switch&quot;</description>
				<copyright></copyright>
		<lastBuildDate>Sun, 06 Sep 2026 05:05:05 +0000</lastBuildDate>
		
					<item>
				<guid>http://aseba.wikidot.com/forum/t-1035096#post-2123744</guid>
				<title>Re: Using a single button as a on/off switch</title>
				<link>http://aseba.wikidot.com/forum/t-1035096/using-a-single-button-as-a-on-off-switch#post-2123744</link>
				<description></description>
				<pubDate>Fri, 03 Oct 2014 12:02:00 +0000</pubDate>
				<wikidot:authorName>UserTO</wikidot:authorName>				<wikidot:authorUserId>1982788</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>wow! Much better solution! thx</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://aseba.wikidot.com/forum/t-1035096#post-2123737</guid>
				<title>Re: Using a single button as a on/off switch</title>
				<link>http://aseba.wikidot.com/forum/t-1035096/using-a-single-button-as-a-on-off-switch#post-2123737</link>
				<description></description>
				<pubDate>Fri, 03 Oct 2014 11:50:58 +0000</pubDate>
				<wikidot:authorName>Michael Bonani</wikidot:authorName>				<wikidot:authorUserId>861355</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Hi,<br /> you can also use the &quot;when&quot; instruction only true when it is changing state</p> <div class="code"> <pre><code>var Status=0 onevent buttons when button.center == 1 do if Status==1 then Status=0 else Status=1 end end</code></pre></div> <p>or the single button event:</p> <div class="code"> <pre><code>onevent button.center if button.center == 1 then if Status==1 then Status=0 else Status=1 end end</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://aseba.wikidot.com/forum/t-1035096#post-2123711</guid>
				<title>Using a single button as a on/off switch</title>
				<link>http://aseba.wikidot.com/forum/t-1035096/using-a-single-button-as-a-on-off-switch#post-2123711</link>
				<description></description>
				<pubDate>Fri, 03 Oct 2014 10:47:36 +0000</pubDate>
				<wikidot:authorName>UserTO</wikidot:authorName>				<wikidot:authorUserId>1982788</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Debouncing a button with a short delay to prevent multiple read. The delay does not effect other program parts. This works fine but maybe there is a better way…</p> <div class="code"> <pre><code>var Status = 0 var delay = 0 timer.period[0]= 100 onevent buttons delay += 1 if delay == 32765 then delay = 25 end #prevent from integer overrun if delay &gt; 25 then #wait for 25 cycles until read buttons if button.center == 1 and Status == 0 then Status = 1 delay = 0 #reset counter elseif button.center == 1 and Status == 1 then Status = 0 delay = 0 end end onevent timer0 if Status == 1 then # do something call leds.top (0, 32, 0) # just a visual control else # do something else call leds.top (0,0,0) end</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>