Before this:First boot & SSH
GPIO basics
Key takeaways GPIO (general-purpose input/output) pins are the SBC’s direct line to electronics: your code can set an output pin high (3.3 V) or low (0 V), or read an input pin’s state. Two safety rules carry the day: pins are 3.3 V logic (5 V kills them) and can source only a few milliamps (LEDs need a resistor; anything bigger needs a transistor or relay). Inputs must never float — a pull-up/pull-down gives them a defined rest state. Blinking an LED and reading a button are the hello-world of physical computing, and everything on the header scales up from them.
Unit 4 turns to the SBC’s defining feature: the double row of pins that no laptop has. The appliance build won’t strictly need them — but the header is why SBCs exist, and thirty minutes with an LED and a button will change how you see every device around you.
What is the header, physically?
Along the board’s edge sit 40 pins (on a Pi and many others). A few are fixed supplies — 3.3 V, 5 V, and ground — and the rest are GPIOs, numbered by the SoC (BCM numbering on a Pi: “GPIO17” is a chip signal name, not physical pin 17 — the perennial beginner trap; always check a pinout diagram).
What are the two rules that protect the board?
- 3.3 V logic, absolutely. A Pi’s GPIOs speak 3.3 V: output high is 3.3 V, and an input must never be fed more. Plenty of hobby electronics (many Arduino modules) are 5 V — connecting their outputs to a Pi input without a level shifter risks the pin or the whole SoC. Check every module’s logic level before wiring.
- Milliamps only. An output pin can safely source roughly 8–16 mA — an LED through a current-limiting resistor (330 Ω is the classic value), no more. A motor, a lamp, a fan: those are switched indirectly — the pin drives a transistor or a relay module, which switches the real current from a proper supply. The pin is a signal, never a power source.
Rule of thumb: before connecting anything to the header, answer two questions — what voltage does it present to the pin? and how much current will flow? If either answer is “not sure,” stop and look it up. Magic smoke is not covered by warranty.
How do you blink an LED from the shell?
Wire the figure’s circuit (long LED leg toward the pin, short leg to ground via
resistor — a breadboard and jumper wires make it solderless). Modern Linux exposes
GPIO through the gpiod tools:
$ sudo apt install gpiod
$ gpiodetect # list GPIO chips
$ gpioset gpiochip0 17=1 # GPIO17 high — LED on
$ gpioset gpiochip0 17=0 # low — off
# blink forever
$ while true; do gpioset gpiochip0 17=1; sleep 0.5; gpioset gpiochip0 17=0; sleep 0.5; done
That shell loop is real physical computing: code changing the world, twice a
second. Every language has libraries wrapping the same interface (Python’s
gpiozero is the gentlest; Go has periph.io) — see
Programming an SBC for the software
side.
How do you read a button — and what is a floating input?
An input pin reads high or low — but a pin connected to nothing reads neither reliably: it “floats,” picking up stray charge and reading back noise. Every input needs a defined rest state via a pull-up (resistor to 3.3 V — rests high) or pull-down (to ground — rests low). SoCs have internal ones you can enable in software. The standard button circuit: internal pull-up on, button wired from pin to ground — released reads 1, pressed reads 0:
$ gpioget --bias=pull-up gpiochip0 27
1 # not pressed
Mechanical buttons also bounce — one press lands as a burst of transitions over a few milliseconds. Libraries debounce for you; just know the word for when a single press “counts” five times.
Where does GPIO go from here?
Single pins get you LEDs, buttons, relays, and fans. Richer devices — sensors, displays, converters — speak protocols over dedicated header pins, which is the next-but-one lesson; whole pre-wired boards stack onto the header as HATs. And on an appliance, GPIO is how you’d add a physical status LED (“decoding now”) or a safe shutdown button — small touches that make a headless box friendlier to the humans living with it.
Quick check: why does a button input need a pull-up or pull-down resistor?
Recap
- GPIO pins are code-controlled wires: outputs you set high/low, inputs you read — meaning defined entirely by what you wire and write.
- The header mixes supplies, grounds, and GPIOs, and chip numbering ≠ physical numbering — always consult a pinout.
- Safety rules: 3.3 V logic (never 5 V into a pin) and milliamps only (LED + resistor direct; bigger loads via transistor/relay).
- Inputs need a pull-up/pull-down or they float; buttons also bounce.
gpioset/gpiogetblink and read from the shell; libraries and buses scale the same idea to real devices.
Next up: USB & powered hubs.
Frequently asked questions
What does GPIO stand for and what is it for?
General-Purpose Input/Output. GPIO pins are wires on the board’s header that your code can drive high or low (output) or read as high or low (input). General-purpose means the board attaches no meaning to them — an LED, a relay, a button, a sensor: whatever you wire up, your software defines what the pin means.
Can GPIO pins damage my board?
Yes, in two classic ways. Feeding a pin more voltage than the board’s logic level (3.3 V on a Pi — 5 V signals are too much) can kill the pin or the SoC, and drawing too much current from an output (pins supply a few milliamps, enough for an LED with a resistor but not a motor) can burn it out. The rules are simple: respect 3.3 V, always use resistors with LEDs, and switch big loads through a transistor or relay board.
Do I need GPIO for the GopherTrunk appliance?
No — the scanner build talks to its radio over USB and needs nothing on the header. GPIO is in this module because it is the SBC’s defining feature and the gateway to the wider embedded world: status LEDs, buttons, fans, and sensors you may well add to an appliance once you have the skill.