GPIO.setup(channel, GPIO.OUT, initial=GPIO.HIGH)
GPIO.setup(channel, GPIO.OUT) GPIO.output(channel, GPIO.HIGH) #state = GPIO.HIGH
initial is the same as to run directly
GPIO.ouput function with the same
state. Do I understand it right? Or do the state:
7. Clean up
At the end of the program, it is good to clean up the channels so that all pins are set in their default state. To clean up all channels used, call:
Here is the talk of “default state”. This means the pinmux default state, not the
initial state from
GPIO.setup function. Do I understand it right?
GPIO.setmode() not working? Why?
# GPIO library import Jetson.GPIO as GPIO # define Pins LED4 = 7 LED8 = 12 LED3 = 13 IN3 = 15 LED7 = 18 IN2 = 19 IN1 = 21 IN7 = 22 LED2 = 23 IN6 = 24 LED1 = 29 IN5 = 32 IN4 = 33 LED5 = 35 LED6 = 38 IN8 = 40 # Pin Definition LED_IN = [IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8] # Warning disable #GPIO.setwarnings(False) # Set up the GPIO channel GPIO.setmode(GPIO.BOARD) GPIO.setup(LED_IN, GPIO.OUT, initial=GPIO.LOW) # ON the LEDs for led_pin in LED_IN: GPIO.output(led_pin, GPIO.HIGH) GPIO.cleanup() print("all LED are ON")
Traceback (most recent call last): File "/home/nvidia/Desktop/error_ON_gpiodemo_forum.py", line 34, in <module> GPIO.output(led_pin, GPIO.HIGH) File "/home/nvidia/.local/lib/python3.9/site-packages/Jetson/GPIO/gpio.py", line 444, in output ch_infos = _channels_to_infos(channels, need_gpio=True) File "/home/nvidia/.local/lib/python3.9/site-packages/Jetson/GPIO/gpio.py", line 119, in _channels_to_infos _validate_mode_set() File "/home/nvidia/.local/lib/python3.9/site-packages/Jetson/GPIO/gpio.py", line 83, in _validate_mode_set raise RuntimeError("Please set pin numbering mode using " RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD), GPIO.setmode(GPIO.BCM), GPIO.setmode(GPIO.TEGRA_SOC) or GPIO.setmode(GPIO.CVM)
Why does this code give the following error?