📅  最后修改于: 2022-03-11 14:57:45.047000             🧑  作者: Mango
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)