Raspberry Pi Wiring Safely
Before connecting anything to your Raspberry Pi's GPIO header, you need to understand why these pins are less forgiving than a typical Arduino or breadboard project, and how resistors, voltage limits, and a careful pre-power routine keep both your board and your components safe.
GPIO Pins Have No Built-In Protection
The 40 pins on a Raspberry Pi's header connect almost directly to the processor's silicon. Unlike a USB port, there is no fuse, no polarity protection, and no automatic current limiting standing between a wiring mistake and the chip itself. A single wrong connection - a wire in the wrong hole, a component wired backwards, two pins accidentally bridged - can damage a GPIO pin permanently, and in some cases take out the whole board. This is the trade-off for having such direct, low-latency control over the hardware: the safety net that exists on consumer ports simply isn't there on the GPIO header.
3.3V Logic, Not 5V
Raspberry Pi GPIO pins operate at 3.3V logic. A pin driven high outputs roughly 3.3V, and a pin reading input treats voltages above about 2V as logic HIGH and voltages near 0V as logic LOW. This trips up people coming from Arduino, where 5V logic is standard - Arduino boards are 5V tolerant, but Raspberry Pi GPIO pins are not. Feeding 5V into a GPIO input pin can immediately and permanently damage that pin, and sometimes the whole SoC, because there is no onboard circuitry to clamp or tolerate the excess voltage.
Why LEDs Need a Current-Limiting Resistor
An LED is not a linear resistor - once it turns on, its own resistance drops very low and the current through it rises sharply for any small increase in voltage. Connected directly across a 3.3V supply with nothing else in the circuit, an LED will try to pull far more current than a GPIO pin can safely supply, which can burn out the LED, overheat the pin, or both. A resistor placed in series with the LED limits that current to a safe level. You can size it with Ohm's law: subtract the LED's forward voltage (about 2.0V for a typical red LED) from your supply voltage, then divide by the current you want the LED to draw (about 15mA is a comfortable, bright-but-safe target).
Resistor value and a basic LED test
# Ohm's law check for a red LED (~2.0V forward voltage, ~15mA target current)
supply_voltage = 3.3
led_voltage = 2.0
target_current = 0.015 # 15 mA
resistor_ohms = (supply_voltage - led_voltage) / target_current
print(resistor_ohms) # about 87 ohms minimum - a common 220 or 330 ohm resistor is a safe, easy choice
from gpiozero import LED
led = LED(17) # GPIO17, wired through the resistor above
led.on()- Power off the Raspberry Pi completely (unplug it) before you connect or change any wiring.
- Wire the circuit on the breadboard first, then double-check every connection against your plan before touching the Pi's header.
- Confirm LED polarity - the longer leg (anode) goes toward the resistor/GPIO side, the shorter leg (cathode) goes toward ground.
- Make sure a resistor is in series with every LED - never connect an LED straight across a GPIO pin and ground.
- Check that no stray jumper wire or component leg is bridging two adjacent breadboard rows.
- Only power the Pi back on once you have compared the physical wiring to your circuit diagram one more time.
A safe test script with cleanup
from gpiozero import LED
from time import sleep
led = LED(17)
try:
led.on()
sleep(2)
finally:
led.off()
led.close() # releases GPIO17 cleanly, even if an error occurred above