On Mon, 19 Feb 2018 19:08:31 -0800 (PST), ewholz@gmail.com declaimed the
following:
>I leave the program running, and detect when door opens, and when door
>closes - but desire just one line of "OPEN" or "CLOSE"
>
Without providing any actual code...
You need to keep a "history" state... AND you need to use an IF/ELSE-IF
structure.
newState = readPin()
if lastState == closed and newState == opened:
print opened
elif lastState == opened and newState == closed:
print closed
lastState = newState
Using two IF blocks, without an ELSE block means the second IF gets
tested even after you execute the contents of the first IF -- and the first
IF (in your code) has set the history such that the other IF triggers and
outputs...
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|