Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › Electronics

Raspberry Pi GPIO pins explained: what each pin does and how to use them safely

By Freedom251 Team · · 11 min read

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Raspberry Pi’s 40-pin header combines fixed power and ground connections with 3.3V GPIO signals. A GPIO pin can be read as an input, driven high or low as an output, or switched to an alternate peripheral such as I2C, SPI, UART or PWM. The safe approach is to identify the exact board, verify the physical-to-BCM numbering, keep every GPIO signal at 3.3V or below, add current limiting for LEDs, and use a driver circuit for motors. Raspberry Pi’s official hardware reference and pin-mapping tables are the final authority for your model: Raspberry Pi computer hardware and its pin/GPIO mappings.

What the 40-pin GPIO header is

The header is a 2-by-20 row of pins on most current full-size Raspberry Pi boards, with a 0.1-inch (2.54 mm) pitch. It is not a block of 40 interchangeable outputs. Some contacts are fixed 5V supplies, some are fixed 3.3V supplies, several are ground returns, and the rest are configurable GPIO signals.

As an Amazon Associate I earn from qualifying purchases.

GPIO means general-purpose input/output. In input mode, the processor samples whether a signal is logically low or high. In output mode, it drives the line low at approximately 0V or high at approximately 3.3V. A pin can also be assigned an alternate function implemented by the SoC, allowing a hardware peripheral to use that contact instead of ordinary GPIO. Changing a pin to an alternate function can make it unavailable for another use at the same time.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fixed supply and return pins

The two 5V contacts are connected to the board’s 5V rail, and the two 3.3V contacts provide the board’s 3.3V rail. Ground contacts are the return path for circuits. None of these fixed pins can be changed into software-controlled GPIO. A 5V pin is a power connection, not a 5V-tolerant logic input.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Configurable GPIO signals

General-purpose pins can be configured as inputs or outputs. Pull-up and pull-down resistors give an input a defined idle state instead of allowing it to float. GPIO2 and GPIO3 have fixed pull-ups in the documented common configuration; software can configure pulls on other GPIOs. Pull resistors are weak biasing devices, not substitutes for a proper power source or load driver.

GPIO numbering versus physical pin numbering

Every header contact has a physical pin number, counting from 1 through 40 on the connector. A signal also has a BCM GPIO number, referring to the SoC’s GPIO controller. These numbers identify different things. For example, the SPI0 MOSI signal is BCM GPIO10 on physical pin 19, while SPI0 SCLK is BCM GPIO11 on physical pin 23.

A wiring diagram that says “GPIO18” means a BCM number unless it explicitly says physical pin 12. If your code uses BCM numbering while you wire by physical numbering, the circuit will be connected to the wrong signal. Before inserting a jumper, run pinout in Raspberry Pi OS or consult the model-specific diagram in the official hardware documentation. Check the connector’s orientation as well; pin 1 is normally marked on the board, and reversing the header view mirrors the entire layout.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

40-pin header reference

The following table shows the standard mapping used by the common 40-pin header. “GPIO” values are BCM numbers. Entries marked as general-purpose can also have additional alternate functions; the table highlights the commonly documented assignments rather than promising that every function is enabled by default on every board.

Physical pin BCM GPIO or fixed connection Common documented role
1 3.3V power Fixed 3.3V supply
2 5V power Fixed 5V supply
3 GPIO2 I2C SDA; fixed pull-up in the common mapping
4 5V power Fixed 5V supply
5 GPIO3 I2C SCL; fixed pull-up in the common mapping
6 Ground 0V return
7 GPIO4 General-purpose or alternate function
8 GPIO14 UART TX in the documented mapping
9 Ground 0V return
10 GPIO15 UART RX in the documented mapping
11 GPIO17 General-purpose or alternate function
12 GPIO18 Hardware PWM-capable pin
13 GPIO27 General-purpose or alternate function
14 Ground 0V return
15 GPIO22 General-purpose or alternate function
16 GPIO23 General-purpose or alternate function
17 3.3V power Fixed 3.3V supply
18 GPIO24 General-purpose or alternate function
19 GPIO10 SPI0 MOSI
20 Ground 0V return
21 GPIO9 SPI0 MISO
22 GPIO25 General-purpose or alternate function
23 GPIO11 SPI0 SCLK
24 GPIO8 SPI0 CE0
25 Ground 0V return
26 GPIO7 SPI0 CE1
27 GPIO0 Reserved for advanced use
28 GPIO1 Reserved for advanced use
29 GPIO5 General-purpose or alternate function
30 Ground 0V return
31 GPIO6 General-purpose or alternate function
32 GPIO12 Hardware PWM-capable pin
33 GPIO13 Hardware PWM-capable pin
34 Ground 0V return
35 GPIO19 Hardware PWM-capable pin
36 GPIO16 General-purpose or alternate function
37 GPIO26 General-purpose or alternate function
38 GPIO20 General-purpose or alternate function
39 Ground 0V return
40 GPIO21 General-purpose or alternate function

GPIO0 and GPIO1 on physical pins 27 and 28 are reserved for advanced uses in the general hardware documentation. Leave them alone unless you understand the interface that owns them and have checked the board documentation.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Common peripheral functions

I2C: GPIO2 and GPIO3

The documented common I2C mapping uses GPIO2 on physical pin 3 for SDA (data) and GPIO3 on physical pin 5 for SCL (clock). I2C devices share those two lines, with each device selected by address. The lines normally need pull-up resistors to the logic supply; use the pull-ups specified by the peripheral or breakout board and keep the bus at 3.3V logic.

UART: GPIO14 and GPIO15

GPIO14 on physical pin 8 is the common UART transmit line, TX. GPIO15 on physical pin 10 is the receive line, RX. A serial connection crosses the signals: one device’s TX goes to the other device’s RX, and both devices need a common ground. Confirm the board’s serial-console and alternate-function configuration before using these pins for your own protocol.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

SPI0: GPIO7 through GPIO11

The standard SPI0 mapping is:

  • GPIO10, physical pin 19: MOSI (controller to peripheral data).
  • GPIO9, physical pin 21: MISO (peripheral to controller data).
  • GPIO11, physical pin 23: SCLK (clock).
  • GPIO8, physical pin 24: CE0 (chip select 0).
  • GPIO7, physical pin 26: CE1 (chip select 1).

SPI can support more peripherals by adding chip-select lines, but the available alternatives depend on the board and its pin-multiplexing configuration. The official pin/GPIO mapping reference lists standard and alternate mappings.

PWM

Software PWM can be generated on all GPIO pins, subject to timing and operating-system load. The documented hardware-PWM-capable pins are GPIO12, GPIO13, GPIO18 and GPIO19, on physical pins 32, 33, 12 and 35 respectively. Hardware PWM is preferable when stable pulse timing matters, but enabling one peripheral can constrain other alternate functions on the same pin.

Electrical levels and current limits

Raspberry Pi GPIO outputs are specified as approximately 3.3V high and 0V low. They are not 5V-tolerant inputs. Applying 5V to a GPIO can damage the SoC, even if the source is connected only briefly. The official warning is: “Do not use 5V for 3.3V components.” Treat sensors, displays and other modules as 3.3V logic unless their documentation explicitly provides safe level shifting.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Do not interpret a drive-strength table as permission to draw that current continuously from a pin. For older BCM2835, BCM2836, BCM2837 and RP3A0-based products, the cited table lists a default drive strength of 8mA and a maximum drive strength of 16mA. For BCM2711-based 4-series devices, it lists a default of 4mA and a maximum of 8mA. Raspberry Pi explains that drive strength describes output behavior, not a simple per-pin current limit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The same documentation notes that the 3.3V supply was designed with a maximum current of approximately 3mA per GPIO pin. This is a design note, not a universal safe-current recommendation. Loading many pins can pull down the 3.3V rail, create voltage drops and switching interference, or destabilize the board. Compute Module users should use the electrical limits in the datasheet for their exact module. When a load needs meaningful power, use a transistor, driver IC or dedicated module powered from an appropriate supply.

How to connect an LED safely

An LED is a small load, but it still must have a series resistor. Without current limiting, the GPIO and LED can draw excessive current and fail. Raspberry Pi’s hardware guidance states: “LEDs should have resistors to limit the current passing through them.” It does not specify one universal resistor value because the correct value depends on the LED’s forward voltage, desired current and circuit supply.

  1. Choose a free GPIO after checking the model-specific pinout. Do not use a 5V, 3.3V or ground pin as the controlled signal.
  2. Connect the GPIO to one end of a suitable series resistor.
  3. Connect the resistor to the LED anode, normally the longer lead. Connect the LED cathode, normally the shorter lead or flat-edged side, to a ground pin.
  4. Check the LED polarity, resistor placement and ground connection before powering the board. The resistor can be on either side of the LED as long as it is in series.
  5. Configure the chosen GPIO as an output and start with it low. Set it high only after confirming that the circuit is wired correctly.

The GPIO high level is about 3.3V, so calculate the resistor from the available voltage, the LED’s specified forward voltage and the target current; then select a standard value that keeps the current conservative. Never assume a resistor that is suitable for one LED or supply is automatically suitable for another.

How to control a motor without damaging the Pi

A motor has a high startup current and generates voltage spikes when its winding current changes. A GPIO cannot supply that current or absorb those transients safely. Raspberry Pi’s explicit guidance is: “Do not connect motors directly to the GPIO pins, instead use an H-bridge circuit or a motor controller board.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
  1. Use a motor-controller or H-bridge rated for the motor’s voltage and stall current.
  2. Power the motor from a suitable external supply through the driver, not from a GPIO output.
  3. Connect a Raspberry Pi GPIO to the driver’s logic input, enable or direction input as required by that driver’s documentation.
  4. Connect the Pi ground to the driver’s logic ground so both devices share a reference. Keep the motor-current path separate from the GPIO signal path.
  5. Use the driver’s built-in flyback protection or the protection components specified by its manufacturer.
  6. Test with the motor unloaded, then monitor for resets, hot components, noise or unexpected GPIO states before applying a mechanical load.

PWM can control speed or power through a driver’s enable input, while separate GPIO lines can select direction. The exact truth table and safe voltage range belong to the driver board, not to the Raspberry Pi header.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Using inputs, pull resistors and switches

A switch input needs a defined state when the contacts are open. Configure an internal pull-up or pull-down where the board and software support it, or add an external resistor sized for the circuit. With a pull-up, wire the switch to ground so an open switch reads high and a closed switch reads low; with a pull-down, wire the switch toward the positive logic rail so the opposite states result.

Always debounce a mechanical switch in software or with suitable hardware. Contact bounce can produce several rapid transitions from one press. Keep switch wiring short, route it away from motor leads, and use a common ground. Never connect a switch that can place 5V directly onto a GPIO input.

Model differences and alternate mappings

The 40-pin mechanical layout is shared by many current boards, but the SoC, boot configuration and enabled peripherals can differ. Alternate functions are multiplexed: assigning a peripheral to a pin can remove it from ordinary GPIO use or conflict with another peripheral. Some boards expose additional routing options, while a Compute Module may have a different carrier-board arrangement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not copy an electrical limit from one family to another. The official documentation separates older BCM2835/BCM2836/BCM2837/RP3A0 products from BCM2711-based 4-series devices, and it directs Compute Module users to the relevant datasheet. Identify the exact model and revision, then verify the active function in software before connecting hardware.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

A safe wiring checklist

  • Read the board-specific pinout and run pinout in Raspberry Pi OS before wiring.
  • Choose one numbering convention and use it consistently in both the diagram and code.
  • Mark physical pin 1 and orient the header correctly.
  • Keep every GPIO signal within the board’s 3.3V logic range; use a level shifter for 5V peripherals.
  • Use a series resistor for every LED.
  • Use a transistor, H-bridge or motor-controller board for motors, relays and other high-current or inductive loads.
  • Connect grounds deliberately and avoid accidental shorts between supply rails.
  • Do not treat a GPIO as a general-purpose power supply.
  • Power down while changing jumper wires, then inspect for reversed polarity or loose strands.
  • After powering up, measure suspicious nodes with a meter and stop if the board resets, a component heats rapidly or a signal is stuck at an unexpected level.

Troubleshooting common mistakes

The program controls the wrong pin

Usually the code uses BCM numbering while the wiring follows physical numbers, or the reverse. Compare the exact number in the code with the table and check the board in pinout. Rewire only after confirming the connector orientation.

An input changes randomly

The input may be floating, missing its pull resistor, or picking up interference from long wires. Enable an appropriate pull-up or pull-down, add an external resistor when required, shorten the wiring and debounce the switch.

An LED does not light

Check that the selected pin is a GPIO rather than power or ground, verify LED polarity, confirm the resistor is in series, and measure the voltage between the GPIO and ground. If the pin was previously exposed to 5V or a short, stop using it until the board has been checked.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A motor resets the board

The motor may be drawing from the Pi’s supply, injecting noise, or lacking a proper driver and shared ground. Move motor power to an appropriate external supply, use an H-bridge or motor controller, follow its protection requirements and keep high-current wiring away from GPIO lines.

An I2C, SPI or UART device is silent

Confirm the documented pins, peripheral enablement and alternate-function selection for the exact board. Check common ground, logic voltage, signal direction and pull-ups. A pin already assigned to another peripheral may not be available for the interface you selected.

Choosing pins for a project

Start with the peripheral requirement, not with an arbitrary free-looking pin. Reserve GPIO2 and GPIO3 when you need the common I2C bus, GPIO14 and GPIO15 for the common UART mapping, and GPIO7 through GPIO11 for SPI0. Select GPIO12, GPIO13, GPIO18 or GPIO19 when a hardware-PWM channel is important. For a simple button or LED, use another ordinary GPIO and document both its BCM and physical numbers in the project notes.

Leave power and ground pins clearly labeled, keep reserved GPIO0 and GPIO1 for systems that explicitly require them, and record any alternate-function settings. That small amount of documentation prevents the most expensive GPIO mistake: wiring a correct circuit to the wrong contact.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

ElectronicsGPIOI2Cmaker projectsPWMRaspberry PiSPIUART

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.