Answers for "timing how long key is pressed raspberry pi"

0

timing how long key is pressed raspberry pi

def my_callback(channel):
    global start
    global end
    if GPIO.input(25) == 1:
        start = time.time()
    if GPIO.input(25) == 0:
        end = time.time()
        elapsed = end - start
        print(elapsed)

  GPIO.add_event_detect(25, GPIO.BOTH, callback=my_callback, bouncetime=200)
Posted by: Guest on June-15-2020

Browse Popular Code Answers by Language