Jetson.GPIO Button Interrupt

Hello, so I am trying to process an interrupt from a button connected to the jetson nano but I am having some trouble. I have been told for 5v from the board I need 1k resistance, so to get this I put 3 resistors in series (334 ohms each) which I then plug that output voltage to one end of the button. For the the other end I connect it to pin 18, using GPIO.setmode(GPIO.BOARD).

With this I then I do:
GPIO.setup(18, GPIO.IN)
GPIO.add_event_detect(18, GPIO.FALLING, callback=mytestfunc, bouncetime=10)
while True:

Should I be using something like:
GPIO.setup(but_pin, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) ?
I don’t have much experience with this stuff so any advice is appreciated!


Not very sure the purpose here.
If Pin 18 is a input pin, then the status of it should be decided by the input instead of controlling by you.

Thanks for the reply Wayne. I am trying to automate the running of a script with a button press, but I’m not sure what you mean by the second part of your response? Where am I controlling the status of the input? Is it in line GPIO.setup(but_pin, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) ? Because I was not sure what that line does. Also I am still having trouble getting the button to work that’s my main issue right now.

For the sample from nvidia the instructions say: “It
requires a button connected to pin 18 and GND, a pull-up resistor connecting
the button to 3V3”. I am not sure how to do this because my button has only two pins?

Well I seemed to have answered my question with this; I guess the Jetson Nano doesn’t let you use pull_up_down resistors like on the raspberrypi. So instead of using that argument in the GPIO.setup I plugged in a resistor with 3.3v going through it to the button at the same pin (of the button) that was connected to pin 18 (on the nano).

In the image above 3.3v is in column b in row 62, pin 18 connection is column b row 58, ground is column b row 56.

Let me clarify what I was trying to say in #2 .

When you set the gpio status to “input” in software, the status of this pin is decided by those hardware circuit you design from external.

Thus, below line is not valid because you still want to set it to “pull down” in software but not from external hardware.

GPIO.setup(but_pin, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)

Anyway, glad it is resolved.