Introduction
Raspberry Pi 4 / 4B is a powerful single-board computer widely used for electronics, robotics, automation, and IoT projects.
Its 40-pin GPIO header is the main interface to connect sensors, motors, LEDs, relays, and other devices. Understanding the pin diagram and functions is essential before starting programming or wiring.
Raspberry Pi 4 / 4B 40-Pin GPIO Layout
Pin Functions
1️⃣ Power Pins
| Pin | Voltage | Purpose |
|---|---|---|
| 1,17 | 3.3V | Power for low-voltage sensors & modules |
| 2,4 | 5V | Power high-voltage modules or motors |
| 6,9,14,20,25,30,34,39 | GND | Ground / common reference |
2️⃣ GPIO Pins
-
General Purpose Input/Output – programmable for controlling LEDs, relays, motors, and reading sensors
-
Examples:
-
GPIO17 → LED control
-
GPIO27 → Button input
-
GPIO18 → PWM for motors or LEDs
-
3️⃣ Communication Pins
| Protocol | Pins | Notes |
|---|---|---|
| I2C | GPIO2 (SDA1), GPIO3 (SCL1) | Connect multiple devices with 2 wires |
| SPI | GPIO7–GPIO11 | High-speed communication with ADCs, sensors |
| UART | GPIO14 (TX), GPIO15 (RX) | Serial communication (GPS, Bluetooth) |
4️⃣ Special Pins
-
PWM Pins: GPIO12, GPIO13, GPIO18 → control motor speed or LED brightness
-
GND Pins: Always connect a ground in circuits
-
3.3V / 5V Pins: Do not short, check voltage compatibility
Tips for Raspberry Pi 4 / 4B Pins
-
Use breadboard & jumper wires for experiments
-
Never connect 5V devices to 3.3V pins
-
Motors and relays need external power, not direct GPIO
-
Always check the pinout before wiring
✅ Conclusion
-
Raspberry Pi 4 / 4B has 40 pins, standardized for power, ground, GPIO, and communication
-
Understanding the pin diagram is essential before any project
-
Once pins are clear, we can move to programming LEDs, sensors, and motors