#Jetson nano 引脚gpio控制

参考链接:GPIO安装文件

#Jetson nano 引脚gpio控制_第1张图片

操作:

下载包https://github.com/NVIDIA/jetson-gpio.git
cd /opt/nvidia/jetson-io/jetson-gpio-master
sudo python3 setup.py install #安装包

代码:

gpio输入

import Jetson.GPIO as GPIO
GPIO.VERSION
GPIO.RPI_INFO
import sys
import time
led_pin = 40
def main ():
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(led_pin,GPIO.IN)
    try:
        while True:
          gpio_state = GPIO.input(led_pin)
          if (GPIO.LOW == gpio_state ):
            print("input vol is low")
          elif (gpio_state == GPIO.HIGH):
            print("input vol is high")
          time.sleep(5)
             
    except:
        print("ERROR")
    finally:
        GPIO.cleanup(led_pin)
if __name__ == '__main__':
    main()

gpio输出

import Jetson.GPIO as GPIO
GPIO.VERSION
GPIO.RPI_INFO
import sys
import time
led_pin = 40
def main ():
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(led_pin,GPIO.OUT)
    try:
        while True:
            GPIO.output(led_pin,GPIO.HIGH)
            time.sleep(5)
            GPIO.output(led_pin,GPIO.LOW)
            time.sleep(5)
            print("led_teggole")
    except:
        print("ERROR")
    finally:
        GPIO.cleanup(led_pin)
if __name__ == '__main__':
    main()

你可能感兴趣的:(jetson,nano,python)