TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: A. DUMAS
from: EWHOLZ@GMAIL.COM
date: 2018-02-24 15:05:00
subject: Re: How to use while loop

On Saturday, February 24, 2018 at 1:57:59 AM UTC-8, A. Dumas wrote:
> On 20/02/2018 06:22, Dennis Lee Bieber wrote:
> > newState = readPin()
> > if lastState == closed and newState == opened:
> >  print opened
> > elif lastState == opened and newState == closed:
> >  print closed
> > lastState = newState
>
> oldState = None
> while True:
>  newState = readPin()
>  if newState != oldState:
>   print(newState)
>   oldState = newState
>  sleep(1)

Hello A Dumas -
Thanks to all who commented and replied. I have implemented a scheme much like
the one above from A. Dumas. It works fine.  I am considering using an
interrupt - but will reply to note below.

Thanks Again,

ewholz

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.