Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!tundraware.eternal-september.org!.POSTED!not-for-mail From: Tim Daneliuk Newsgroups: comp.lang.python Subject: Re: RPI.GPIO Help Date: Mon, 31 Aug 2015 14:07:58 -0500 Organization: A noiseless patient Spider Lines: 26 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: tundraware.eternal-september.org; posting-host="5a15fedc1d2651a6099f1673ffb218fd"; logging-data="22910"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zUKWdA59GWjv1qQuaLo9P8/iPBgokttk=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 In-Reply-To: Cancel-Lock: sha1:2Ltn8jQ45rj7M0gz+hTHU1HVN80= X-Enigmail-Draft-Status: N1110 Xref: csiph.com comp.lang.python:95797 On 08/16/2015 02:40 PM, John McKenzie wrote: > > Hello, all. I am hoping some people here are familiar with the RPi.GPIO > python module for the Raspberry Pi. I am not familiar with the module, but I am quite familiar with dealing with hardware interfacing, mostly in assembler. One thing you need to ensure is that either the module or your code implents software debounce. When a button is pressed or switched moved, there is mechanical bounce for a some period of time immediately thereafter. In the time right after the switch/button is pressed, the mechanical closure "bounces" between "on" and "off" for a little while, until it settles down to the position you've selected. The idea is to use the initial change of state to initiate the button handling logic but wait until the switch/button settles down to it's final (and therefore, reliable) state. One algorithm to do this is to wait a fixed amount of time after the initial event - say, 100ms - before reading the switch. The other way to do is to read the button/switch state ever few milliseconds and only accept the input if it has not changed in, say, 5 measurements. HTH,