Build it step by step
0 of 7 donePower off
Before wiring.
Check the header pin map
For your model.
Wire the LED
Through 220 ohm to GND.
Wire the button
With the pull-up to 3.3 V.
Run the script
python3 button_led.py.
Press the button
LED follows it.
Try a pin change
Check the jetson-io tool.
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
- Single Board ComputersBuy
- SemiconductorsBuyLED 5 mm red × 1
- PassivesBuyResistor 220 Ω × 1
- SwitchesBuy
- PassivesBuyResistor 10 kΩ × 1
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Header pin 7 | 220 ohm resistor, then red LED anode, LED cathode to GND (pin 6) | LED (3.3 V logic) |
| Header pin 15 | Button, with 10 k to 3.3 V (pin 1) | Button input (reads LOW when pressed) |
| Button other side | GND (pin 9) | Return path |
| Jetson | Power supply as per your model | Power |
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.
| Check | Expected |
|---|---|
| Script started | Prompt printed |
| Button down | LED on |
| Button up | LED off |
| Ctrl+C | Pins 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 →
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.
