<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Use a GPIO as a Button]]></title><description><![CDATA[<p dir="auto">I want to be able to use a GPIO as a button, I can check the state of a GPIO pin with cat but I would not like to poll it several times per minute because it eats cpu. Is there any way to do it.</p>
]]></description><link>http://community.onion.io/topic/814/use-a-gpio-as-a-button</link><generator>RSS for Node</generator><lastBuildDate>Wed, 11 Mar 2026 06:58:37 GMT</lastBuildDate><atom:link href="http://community.onion.io/topic/814.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 01 Jun 2016 11:21:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Use a GPIO as a Button on Wed, 01 Jun 2016 11:21:03 GMT]]></title><description><![CDATA[<p dir="auto">I want to be able to use a GPIO as a button, I can check the state of a GPIO pin with cat but I would not like to poll it several times per minute because it eats cpu. Is there any way to do it.</p>
]]></description><link>http://community.onion.io/post/5772</link><guid isPermaLink="true">http://community.onion.io/post/5772</guid><dc:creator><![CDATA[yaseen almanna]]></dc:creator><pubDate>Wed, 01 Jun 2016 11:21:03 GMT</pubDate></item><item><title><![CDATA[Reply to Use a GPIO as a Button on Wed, 01 Jun 2016 12:24:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/1311">@yaseen-almanna</a> What you need is to be able to catch interrupts on the GPIO pin.  I am not aware of any standard software package that easily accomplishes this.<br />
However, I have written a C/C++ code library that can do this (amongst other things).<br />
I also have written a standalone program that also allows you to set up for a command to be automatically run whenever the GPIO pin state changes.<br />
I have published the code and program at <a href="https://github.com/KitBishop/new-gpio" rel="nofollow">https://github.com/KitBishop/new-gpio</a><br />
Full documentation is in the file <strong><code>new-gpio.pdf</code></strong><br />
The easiest form of the program (<code>new-gpio</code>) to use is at <a href="https://github.com/KitBishop/new-gpio/tree/master/bin/new-gpio/static-linked" rel="nofollow">https://github.com/KitBishop/new-gpio/tree/master/bin/new-gpio/static-linked</a><br />
Copy the program to a suitable location on your Omega.  Then, to use it to run a command whenever a designated GPIO pin changes state, use a command like:</p>
<ul>
<li><strong>./new-gpio -s irq <code>&lt;pin-number&gt;</code> rising "<code>&lt;command-to-execute&gt;</code>" 200</strong><br />
Where <strong><code>&lt;pin-number&gt;</code></strong> is the number of the GPIO pin<br />
<strong><code>rising</code></strong> indicates that the change of level from low to high is used to trigger the interrupt (use <code>falling</code> if you want high to low to trigger it)<br />
<strong><code>&lt;command-to-execute&gt;</code></strong> is the command that will be executed whenever the pin undergoes the relevant change - MUST be enclosed in quotes (<strong><code>"</code></strong>) if it contains any special characters<br />
The <strong>200</strong> is a debounce time (in milliseconds) to allow for possibly noisy mechanical switches that could potentially trigger spurious interrupts.</li>
</ul>
<p dir="auto">Whenever the pin undergoes the relevant change, the given command will be executed.</p>
<p dir="auto">When you no longer want the pin to trigger the command, it can be stopped using:</p>
<ul>
<li><strong>./new-gpio -s irqstop <code>&lt;pin-number&gt;</code></strong></li>
</ul>
<p dir="auto">Hope that helps <img src="http://community.onion.io/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=ic093v0mjao" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" title=":-)" alt="🙂" /></p>
]]></description><link>http://community.onion.io/post/5776</link><guid isPermaLink="true">http://community.onion.io/post/5776</guid><dc:creator><![CDATA[Kit Bishop]]></dc:creator><pubDate>Wed, 01 Jun 2016 12:24:28 GMT</pubDate></item><item><title><![CDATA[Reply to Use a GPIO as a Button on Thu, 02 Jun 2016 08:09:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="http://community.onion.io/uid/19">@Kit-Bishop</a> Thank you nice work, it will help alot.</p>
]]></description><link>http://community.onion.io/post/5780</link><guid isPermaLink="true">http://community.onion.io/post/5780</guid><dc:creator><![CDATA[yaseen almanna]]></dc:creator><pubDate>Thu, 02 Jun 2016 08:09:47 GMT</pubDate></item></channel></rss>