GPIO (General-Purpose Input/Output)

GPIO, short for general-purpose input/output, is the simplest and most fundamental way a processor touches the outside world. A GPIO pin is a single physical connection whose behavior is not fixed at the factory but chosen by software at run time. Configured as an input, the pin reports whether the voltage on it is high or low, letting the chip read a button, a switch, or the output of a sensor. Configured as an output, the pin drives its line high or low, letting the chip turn on an LED, energize a relay, or signal another device.

On real hardware, GPIO is controlled through memory-mapped registers. The Broadcom BCM2835, the system-on-chip at the heart of the original Raspberry Pi, is documented in the BCM2835 ARM Peripherals datasheet, which devotes a chapter to its 54 general-purpose I/O lines. The datasheet describes the function-select registers (GPFSEL) that choose whether each pin is an input, an output, or one of several alternate peripheral functions; the set and clear registers (GPSET and GPCLR) that drive an output high or low; and the level registers (GPLEV) that read an input. Writing a bit in GPSET, for example, is exactly what a high-level call like digitalWrite resolves to underneath.

That alternate-function detail is what makes the word general-purpose meaningful. A single pin is rarely just a dumb on/off line. The same physical pin can usually be switched to act as part of a serial bus such as I2C, SPI, or a UART, or as a pulse-width-modulation output, depending on which alternate function the function-select register chooses. The board designer and the programmer decide, per pin, whether it is a plain GPIO or a dedicated peripheral signal.

Beyond reading and writing levels, GPIO inputs typically support edge and level detection that can raise an interrupt, so the processor does not have to poll a pin in a busy loop. The BCM2835 documentation lists event-detect registers for rising edges, falling edges, and high or low levels, each able to flag the processor when a pin changes. Pins also commonly have configurable internal pull-up or pull-down resistors so that an unconnected input settles to a known state rather than floating.

The reason GPIO matters so much in embedded and hobbyist computing is the header. The two-row pin header on a Raspberry Pi or the labeled sockets along an Arduino board expose these GPIO lines physically, where anyone can connect a wire. That accessibility, combined with a register model simple enough to explain in a few paragraphs, is why GPIO is usually the first thing a newcomer drives and the foundation on which the higher-level buses in this collection are built.