Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, Teaching Physical Computing with Raspberry Pi and Python. Join the course to learn more.

General Purpose Input Output on the Raspberry Pi

The GPIO pins are one way in which the Raspberry Pi can control and monitor the outside world by being connected to electronic circuits.

The Pi can control LEDs, turning them on or off, drive motors, and interact with many other objects. It can also detect the pressing of a switch, change in temperature, or light, etc, by attaching kinds of sensors. We refer to all these activities, and more, 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. Using them, 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!)

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

26 pin layout

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, a reference board that fits over the pins or a website guide 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