In my previous article – Anatomy of Raspberry Pi, we talked about GPIO (General Purpose Input Output). In this article we will discuss more about the GPIO pins, function of each pin on the Pi board and GPIO numbering.

Getting Started:

The main difference between a Raspberry Pi (tiny computer) and other computers is the GPIO (General Purpose Input Output) pins (see Fig. 1)

fig-1                              Fig. 1

Desktop computers are UBIQUITIOUS i.e. they have a standard input and output (files, keyboard, mouse, touch, print, screen etc.) and they take information from fixed input, process it and give the results back to the standard output. This means a normal computer / machine do not have an interface to connect with electronic devices like sensor and actuators, this is where the Raspberry Pi (tiny computers) GPIO pins play and important role and make Raspberry Pi different from other computers.

The Pi has GPIO pins that stick out from the top of the board, these pins act as interface between the Raspberry pi and the physical world. These pins are used to communicate (both input / output) with other circuitry such as sensors, actuators, extension boards and custom circuits.

Understanding the Pins

As seen in Fig. 2 above the GPIO pins vary based on the Raspberry Pi model. The previous models have 26 pins and latest models – Raspberry Pi 2 Model B and Raspberry Pi 3 Model B both have 40 Pins.

fig-2                       Fig. 2

To maintain backward compatibility the first 26 pins from previous models still have same functionality in the new Raspberry pi models. (See Fig. 3)

fig-3                                                         Fig. 3

As seen in Fig. 4 each pin on the Raspberry pi has a function to do and also an alternate function assigned. You can consider these pins like switches which have a function / Alternate function to do and which can turned on or off. Apart from the regular function / standard I/O pins (GPIO), the alternate functions these pins have are GND (ground), SPI (Serial Peripheral Interface Bus), I2C (inter integrated circuits), power pins and UART (Universal asynchronous receiver /transmitter) pins.

fig-4                                                 Fig. 4

GPIO numbering:

As seen in Fig. 4 above the GPIO pins diagram it seems to be pretty complex and confusing and there is no easy way to remember each of the pins, you need to keep a printed reference sheet on top when using them.

There is a solution to this problem and In the Raspberry Pi world there are two different numbering schemes used when referencing Pins.

  1. Using the BCM – Broadcom chip-specific pin number – example GPIO 10, GPIO23, GPIO24 etc.
  2. Physical numbering – where each number is based on the physical position of the pin. (Hold the Raspberry Pi up facing you vertically with the pins on the right side then start counting from top left as pin 1 and next pin as 2 on the first row and the pin below 1 as 3 and below 2 as 4 and so on)

fig-6Fig, 5                                                          Fig. 6

Note: You are free to use any of the above GPIO numbering system, but while invoking  the GPIO pins in programs ( like python or C # ), you code should reference to one of the numbering system you are going to use.

Example In a Python program – code looks like this

import RPi.GPIO as GPIO

GPIO.BOARD – is the physical numbering system and GPIO.BCM is the Broadcom number system.

Don’t worry if you don’t understand the above code. We will learn all about in future articles.

Important Warning: You have to be careful when connecting devices, the GPIO pins directly with wires (called jumper cables)- if these wires are connected to wrong pins, it might damage the Pi board, so please read the instructions carefully before connecting wires directly to the pins.

I would highly recommend using a Breadboard – where you can create the dummy circuits on the breadboard and then connect only to the required pins on the Pi. I would also recommend using a “breakout circuit” to connect the Raspberry Pi with breadboard. One end breakout board is connected to the Raspberry Pi and the other end into the breadboard.


In the Next Article we would talk on about Breadboard and make our first circuit.

Hope this Helps.

Happy Learning Happy Making

Raspberry Pi – Understanding GPIO

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *