Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4954

Automation, sensing and robotics • Re: Sequent microsystems 8 relay hat weirdness

$
0
0
Possibly your getkey-procedure has problems with the USB-connected feather.
Let me propose to use a python standard input method:

Code:

import timeimport lib8relinddef relay_on(relay):    lib8relind.set(0,relay,1)    def relay_off(relay):    lib8relind.set(0,relay,0)    k = input("relay number [1..8]: ")print( f"user provided input {k}")if k in ['1','2','3','4', '5','6','7','8']:    print("k is in range of valid relay numbers")    relay = int(k)    relay_on(relay)        print("stop with ctrl-c")    try:        while True:            time.sleep(0.1)    except KeyboardInterrupt:        pass        relay_off(relay)        

Statistics: Posted by ghp — Thu Oct 10, 2024 10:40 am



Viewing all articles
Browse latest Browse all 4954

Trending Articles