执行演示代码
执行以下操作,以在昉·星光 2的Debian系统上运行演示代码:
- 找到测试代码pud_test.py所在的目录:
- 在sample-code目录下,执行以下命令以运行演示代码:
sudo python pud_test.py
或者,您也可以执行以下命令:
sudo python3 pud_test.py
结果:终端显示如下:
# python3 pud_test.py *----------------------Start testing------------------------------* Step 1: set input to direction of GPIO pin 31. Step 2: the default input level is HIGH. Step 3.1: set PUD_DOWN to input direction of GPIO pin 31. Step 3.2: the input level with pull_down enabled is LOW. Step 4.1: set PUD_UP to input direction of GPIO pin 31. Step 4.2: the input level with pull_up enabled is HIGH. *---------------------------end test------------------------------*
结果显示GPIO PUD功能正常。