fbpx

Raspberry Pi GPIO Pins

What is GPIO?

One of the most useful characteristics of all models of the Raspberry Pi is that it comes with a set of General-Purpose Input/Ouput pins, or GPIO. However, the pins are not actually labelled on the board, so it can be confusing to know what pin serves what purpose.

Turn Your Board

To start, let’s take a look at the physical board, and orient it in a consistent way so that we can line it up to a diagram more naturally. First, locate the GPIO pins — they will be two rows of 13 or 20 pins, depending on the model of Raspberry Pi you have. Turn your board so that the pins are on your right side, forming two colums, as shown below.

Physical Pin Numbers

Now, starting from the top left and moving like you read a book, we can give the physical pins numbers, starting from #1. So the top right pin is #2; the bottom left pin is #39; the bottom right pin is #40. NOTE: If you have an early model of the Raspberry Pi, you might only have 26 pins in total.  The pins you have still serve the same purpose, you just have 9 fewer general purpose pins to work with.

Pin Functions

The physical pin numbers just help us locate pins for connecting our circuits, they don’t actually tell us anything about it’s purpose, or how computer programs will refer to them. If you want to find this information straight from the source, you can look up the documentation for the System-on-a-Chip used by the Raspberry Pi: Broadcom BCM2835

We’ll save you some effort and summarize it below.

Pin Function Descriptions

Generally, all of the pins can be used for general inputs and outputs. When using the RPi.GPIO Python module to program your Raspberry Pi, you can refer to the GPIO pin name. The names in brackets are for special functionality that are available when the GPIO is configured in other modes. For example:

  • In TXD/RXD mode the GPIO may be used as a serial link (many devices can communicate via a serial link).
  • In I2C mode the GPIO may be used to implement an I2C bus (many sensors, e.g. RTC (Real Time Clock), can communicate via I2C).
  • In SPI mode the GPIO may be used to implement a SPI bus (many sensors, e.g. ADC (Analog Digital Converter), can communicate via SPI).
  • Other potentially useful modes are CLK (for generating a clock signal) and PWM (Pulse Width Modulation) for setting motor speed, driving servos, dimming LEDs etc.

These modes are not implemented in RPi.GPIO yet, so most projects don’t need to worry about them.

Share this post!

join the coding club!

Sign up to be the first to know about new classes and promos!