Jetson.gpio mode already set?

I’m trying to trigger a relay using my Jetson Nano with GPIO, but using the following code I get an error that “A different mode has already been set!”

    #!/usr/bin/env python
    import Jetson.GPIO as GPIO
    import time
    from adafruit_servokit import ServoKit
    # Pin Definitions
    output_pin = 18  # BOARD pin 12, BCM pin 18
    kit = ServoKit(channels=16)
    # Pin Setup:
    # Board pin-numbering scheme
    mode = GPIO.getmode()
    # set pin as an output pin with optional initial state of HIGH
    GPIO.setup(output_pin, GPIO.OUT, initial=GPIO.LOW)
    print("Mode is %s" % mode)
    def turn_on_relay():
    	while True:
    		choice  = input('Enter 1 to turn on, Enter 0 to turn off; Q to quit: ')
    		if choice == '1':
    			GPIO.output(output_pin, GPIO.HIGH)
    		elif choice == '2':
    			GPIO.output(output_pin, GPIO.LOW)	
    		elif choice == 'q':

Resulting error is:

Traceback (most recent call last): File “”, line 12, in

GPIO.setmode(GPIO.BCM) File “/usr/local/lib/python3.6/dist-packages/Jetson.GPIO-2.0.8-py3.6.egg/Jetson/GPIO/”,
line 312, in setmode ValueError: A different mode has already been
set! Exiting… Cleaning up pins

Why can’t I set the mode?

I guess it probably means this pin has been occupied by some drivers. What pin are you using?

Hi briwil1978,

Have you managed to get it working? Or it’s still an issue to support?

I had some problems with the oled display form adafruit.
I solved changing the init line form: “oled = Adafruit_SSD1306.SSD1306_128_32(rst=None, i2c_address=0x3C)”

To: “oled = Adafruit_SSD1306.SSD1306_128_32(rst=None, i2c_bus=1, gpio=1)”

It seems that the problems comes only when forcing the adress and not when you give the whole bus

Glad to know the issue resolved, thanks for the update.