create.withcode.uk
Raspberry Pi Python GPIO Quick start guide
The GPIO pins on a Raspberry Pi allow you to connect your Pi up to all sorts of electronic devices. This guide talks you
through how to set up and control the inputs and outputs using python.
GPIO stands for General Purpose Input and Output.
GPIO pins are the metal spikes that stick out of a RPi.
Older RPis have 26 pins and newer ones have 40 pins.
Some of those pins are for power rather than inputs or
outputs
Pins:
Pins are either power points or I/O pins
Power pins are hard wired to 0v (ground), +3.3v or +5v. You can’t change them.
I/O pins can be set to either an input or an output
Inputs read a digital value into the RPi (e.g. has a switch been pressed?)
Output send a digital value out from the RPI (e.g. switch an LED on or off)
Pin numbering:
There are two numbering systems for GPIO pins.
Physical numbering is the easiest to understand: it tells you where to find the pin on the physical RPi board
(see below)
BCM numbers are only for I/O pins. They don’t match the physical numbers but come from the way that
they are connected to the processor on the RPi.
When writing your code you can choose to use either physical numbering or BCM numbering
Warning:
You might permanently break your RPi if you’re not careful when connecting anything to the GPIO pins.
Short circuits (conn3v or +5 either from a power pin or an output pin directly to ground) will
damage your RPi
Whilst your GPIO pins have power pins, there’s a limit to how much power they can provide. You may need
an external power supply if you’re controlling a circuit that needs anything more than a few LEDs &
switches.
Never connect a motor or speaker directly to a GPIO pin. The electrical feedback can cause damage.
RPi
Model
Number
of GPIO
pins
Number of
inputs or
outputs
A
26
17
B
26
17
A+
40
28
B+
40
28
Pins 27-40 not available on older RPi models
Pin 1
Pin 40
Pin 2