TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: DENNIS LEE BIEBER
from: A. DUMAS
date: 2018-02-24 10:57:00
subject: Re: How to use while loop

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)

--- 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™.