Ahoj napsal jsem si jednoduchy program na blikani diody ovladane z klavesnice.Nevim ale jakou podminku mam dat do cyklu while aby mi program reagoval okamzite jak zmacknu klavesu.Ted to funguje tak ze menit parametry doby zhasnuti jdou nastavovat jen po zhasnuti diody
import RPi.GPIO as GPIO
import time
import keyboard
from sys import exit
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.OUT)
doba_sviceni = 4
doba_zhasnuti = 6
while True:
if keyboard.is_pressed("+"):
doba_zhasnuti = doba_zhasnuti + 1
time.sleep(0.2)
print("vydech je",doba_zhasnuti,"s")
elif keyboard.is_pressed("-"):
doba_zhasnuti = doba_zhasnuti - 1
time.sleep(0.2)
print("vydech je",doba_zhasnuti,"s")
elif keyboard.is_pressed("r"):
doba_zhasnuti = 6
print("doba vydechu je 6s")
time.sleep(0.2)
elif keyboard.is_pressed("q"):
GPIO.cleanup()
exit()
else:
GPIO.output(14, True)
time.sleep(doba_sviceni)
GPIO.output(14, False)
time.sleep(doba_zhasnuti)