Projects / GPIO on a Jetson

GPIO on a Jetson

Beginner45 minGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANO

    Power off

    Before wiring.

  2. NANO

    Check the header pin map

    For your model.

  3. NANO14.6 mA

    Wire the LED

    Through 220 ohm to GND.

  4. NANO

    Wire the button

    With the pull-up to 3.3 V.

  5. NANO14.7 mA

    Run the script

    python3 button_led.py.

  6. NANO14.7 mA

    Press the button

    LED follows it.

  7. NANO

    Try a pin change

    Check the jetson-io tool.

In short

How do you build a GPIO on a Jetson?

Use Python on a Jetson to read a button and blink an LED, like a Pi. You need NVIDIA Jetson Orin Nano Super Developer Kit, LED 5 mm red, Resistor 220 Ω, Tactile push button 6 mm, Resistor 10 kΩ, Breadboard 830 Tie Points and Jumper wires male to female (40 pcs). It takes 7 steps and about 45 minutes.

Level
Beginner
Time
About 45 min
Parts
7

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Header pin 7220 ohm resistor, then red LED anode, LED cathode to GND (pin 6)LED (3.3 V logic)
Header pin 15Button, with 10 k to 3.3 V (pin 1)Button input (reads LOW when pressed)
Button other sideGND (pin 9)Return path
JetsonPower supply as per your modelPower

Code

The Jetson's 40-pin header looks like a Raspberry Pi's, and the Jetson.GPIO library, which is preinstalled on JetPack, copies the RPi.GPIO calls, so code is similar. The logic is 3.3 V and each pin gives only a few milliamps, so always use the resistor with the LED and never connect 5 V to an input. Some header pins are shared with other functions such as serial, I2C and PWM, and on certain models they start with those functions, so check the pin map for your model and, if a pin does not respond, use the jetson-io tool (sudo /opt/nvidia/jetson-io/jetson-io.py) to set it as a GPIO. Power the board off before wiring. Run the script with python3, and if you see a permission error, add your user to the gpio group or run it with sudo for a first test.

import time
import Jetson.GPIO as GPIO

LED_PIN = 7        # board numbering, 40-pin header pin 7
BUTTON_PIN = 15    # board numbering, 40-pin header pin 15

GPIO.setmode(GPIO.BOARD)
GPIO.setup(LED_PIN, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(BUTTON_PIN, GPIO.IN)

try:
    print("Press the button to light the LED. Ctrl+C to quit.")
    while True:
        pressed = GPIO.input(BUTTON_PIN) == GPIO.LOW
        GPIO.output(LED_PIN, GPIO.HIGH if pressed else GPIO.LOW)
        time.sleep(0.02)
finally:
    GPIO.cleanup()

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Script startedPrompt printed
Button downLED on
Button upLED off
Ctrl+CPins released

If it does not work

LED never lights

Check the pin number and that it is a GPIO pin on your model.

Permission error

Use the gpio group or sudo.

Button reads always low

Check the pull-up goes to 3.3 V, not 5 V.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the GPIO on a Jetson?

NVIDIA Jetson Orin Nano Super Developer Kit, LED 5 mm red, Resistor 220 Ω, Tactile push button 6 mm, Resistor 10 kΩ, Breadboard 830 Tie Points and Jumper wires male to female (40 pcs).

How long does the GPIO on a Jetson take to build?

About 45 minutes for a beginner maker, in 7 steps.

How do I know the GPIO on a Jetson works?

Script started: Prompt printed. Button down: LED on. Button up: LED off.

LED never lights: what should I check?

Check the pin number and that it is a GPIO pin on your model.

Permission error: what should I check?

Use the gpio group or sudo.

Button reads always low: what should I check?

Check the pull-up goes to 3.3 V, not 5 V.