Created
October 11, 2020 08:59
-
-
Save Torstein-Eide/67a4b9a1140b5a47a2412f2ca40d0c82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time, keyboard # using module keyboard | |
A = 0 | |
q = False | |
w = False | |
komfeil = 2 | |
while True: # making a loop | |
time.sleep(0.1) | |
try: # used try so that if user pressed other than the given key error will not be shown | |
## Forbindelse feil blokkert | |
if keyboard.is_pressed('w'): # if key 'w' is pressed | |
if w: | |
w = False | |
else: | |
w = True | |
## kommunikasjonsfeil blokkert | |
if keyboard.is_pressed('q'): # if key 'q' is pressed | |
if q: | |
q = False | |
else: | |
q = True | |
if keyboard.is_pressed('a'): # if key 'a' is pressed | |
raw = raw + 0.1 | |
else: | |
raw = 0 | |
if raw > komfeil and q == False: | |
print("1", int(q == True), "0", int(w == True),' raw=',round(raw, 1), 'komunikasjon feil' ) | |
elif raw > 0.1 and w == False : | |
print("0", int(q == True), "1", int(w == True),' raw=',round(raw, 1), 'forbindelse feil' ) | |
elif raw == 0 or w == True: | |
print("0", int(q == True), "0", int(w == True),' raw=',round(raw, 1), 'forbindelse OK' ) | |
except: | |
break # if user pressed a key other than the given key the loop will break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment