General Purpose Input Output on the Raspberry Pi

The GPIO pins are a way in which the Raspberry Pi can control and monitor the outside world by being connected to electronic circuits. The Pi is able to control LEDs, turning them on or off, or motors, or many other things. It is also able to detect the pressing of a switch, change in temperature, or light etc. We refer to this as physical computing.


Most models of the Raspberry Pi have 40 pins that look like this:

GPIO pins

These pins are a physical interface between the Raspberry Pi and the outside world. You can program the Raspberry Pi to switch devices on and off (output), or receive data from sensors and switches (input). Of the 40 pins, 26 are GPIO pins and the others are power or ground pins (plus two ID EEPROM pins which you should not play with unless you know your stuff!)

GPIO layout

Early models A and B have only 26 pins, and look like this:

26 pin layout

Note that the numbering of the GPIO pins is rather unusual. This is explained in the section on pin numbering, below.

GPIO Pin Numbering

When programming the GPIO pins there are two different ways to refer to them: GPIO numbering and physical numbering. Throughout this course (and in all our resources) we will refer to the pins using the GPIO numbering scheme. These are the GPIO pins as the computer sees them. The numbers don’t make any sense to humans, they jump about all over the place, so there is no easy way to remember them. However, you can use a printed reference or a reference board that fits over the pins to help you out.

GPIO layout

Share this article:

This article is from the free online course:

Teaching Physical Computing with Raspberry Pi and Python

Raspberry Pi Foundation