Jetson 共用资料

Ubuntu18.04 Python调用GPIO测试

2023-07-25 admin 98

Ubuntu18.04 Python调用GPIO测试

1. 安装gpio python library

git clone https://github.com/vitiral/gpio.git

cd gpio/

sudo python3 setup.py install


2. 编写以及运行下列Python参考示例代码

import time

import gpio

 

tst_gpio_pin = 417    #417对应T609G扩展的GPIO17

#tst_gpio_pin = 290    #290对应T609G扩展的GPIO04

#tst_gpio_pin = 258    #258对应T609G扩展的GPIO10

#tst_gpio_pin = 343    #343对应T609G扩展的GPIO02

 

gpio.setup(tst_gpio_pin, gpio.OUT)

gpio.set(tst_gpio_pin, 0)

 

print("Starting now! Press CTRL+C to exit")

try:

    while True:

        gpio.set(tst_gpio_pin, 1)

        print("TEST High.")

        time.sleep(5)

        gpio.set(tst_gpio_pin, 0)

        print("TEST Low")

        time.sleep(5)

finally:

    gpio.cleanup()

 

3. 通过如下查看设置HI LO

sudo cat /sys/kernel/debug/gpio| grep '417'


首页
产品
案例
联系