执行演示代码
执行以下操作,以在昉·星光 2的Debian系统上运行演示代码:
- 找到测试代码edge_detection_with_waiting_time.py所在的目录:
- 在sample-code目录下,执行以下命令以运行演示代码:
sudo python edge_detection_with_waiting_time.py
或者,您也可以执行以下命令:
sudo python3 edge_detection_with_waiting_time.py
结果:- 终端显示如下:
# python3 edge_detection_with_waiting_time.py *-----------------------Case 1-----------------------------------------------------* Note: don't press the key on pin 37 once within 5 seconds !!!
- 等待5秒后,终端显示如下:
Edge hasn't been detected within 5 seconds while setting 5 seconds to timeout. The return value of GPIO.event_detected(37) within 5 seconds: False *-----------------------Case 2-----------------------------------------------------------------------* Please press the key on pin 37 once at any time !!!
- 最后根据提示按下按键,终端显示如下:
Edge has detected while setting -1 to timeout, timeout -1 means waiting until edge is detected. The return value (True) of GPIO.event_detected(37) should be True. The return value (False) of GPIO.event_detected(37) should be False, because of the secondly reading.
- 终端显示如下: