Introduction to the Raspberry Pi 

Lesson ​​​​​​1​​2

​​​Raspberry Pi pins, roles, and numbers

​It is time to dig into your first hands-on experiments. In the next few chapters you will learn how to work with an LED and a button using Python. This is the first step towards doing much more interesting things.

On the Raspberry Pi, you can connect external devices, like buttons and LEDs, to the various pins that are exposed through a 40-pin header. Each of the pins perform specific functions.

Most of the pins can perform multiple functions, as you will see later.

There are two attributes that are most important when it comes to the Raspberry Pi pins:

  • ​The pin number, which allows you to refer to a pin inside your Python scripts
  • The pin capabilities, so that you know what it is that you can do with a pin.

​Let’s have a look at some examples:

  • ​Pins 1 and 17 provide 3.3V power.
  • Pins 2 and 4 provide 5V power
  • Pins 6, 9, 14, 25, 30, 34 and 39 are GND.
  • Pin 22 is a general-purpose input/output (GPIO) pin. You can use it to drive an LED or sense the state of a button.
  • Pin 14 is a GPIO, but also the transmit pin of the UART (serial interface).
  • Pin 32 is a GPIO, but also a PWM pin.

​In the diagram below​ you can see a full map of the Raspberry Pi 40-pin header. The map shows the primary and secondary function of each pin.

This is a map of the Raspberry Pi 40-pin header, with information about the primary and secondary role of each pin (borrowed from

​A handy tool to have on your Raspberry Pi is pinout, a component of a library called GPIO Zero. With pinout, you can see a simple header map and basic information about your Raspberry Pi on your command line. It looks like the example ​below.

Pinout is a handy utility that shows basic information about your Raspberry Pi and a map of its header.

​Pinout is already installed in the full version of Raspbian, but not in Lite.

To install pinout in Raspbian Lite, issue this command:

$ sudo apt install python3-gpiozero

To show the pin map, type this:

​$ pinout

​As you can see in these two maps, each pin has two numbers. For example, with reference to ​screenshot from the Pinout output above, the second pin from the top in the left column is “GPIO2 (3)”.

This means that you can refer to this pin in two ways in your Python scripts:

  • ​With its GPIO reference number, which is “2”.
  • With its board reference number, which is “3”.

​Similarly, for “GPIO11 (23)”, the GPIO number is 11, and the board number is 23.

In the scripts in this project we will use the GPIO numbering system unless noted otherwise.

"Raspberry Pi Getting Started" series

Ready for some serious learning?

Start right now with Raspberry Pi Full Stack - Raspbian

This is our most popular Raspberry Pi course & eBook.

This course is a hands-on project designed to teach you how to build an Internet-of-Things application based on the world’s most popular embedded computer.

​You will learn how to build this application from the ground up, and gain experience and knowledge with technologies such as...

  • ​The Linux operating system and the command line, 
  • The Python ​programming language,
  • ​The Raspberry Pi General Purpose Input Output pins (GPIOs), 
  • ​T​he Nginx web server,
  • ​​The Flask Python web application microframework​,
  • JQuery and CSS for creating user interfaces,
  • ​How to deal with timezones, 
  • ​How to create charts with Plotly and Google Charts, 
  • ​How to do datalogging with Google Sheet, 
  • ​How to create applets with IFTTT, ​
  • ​How to secure your application with SSL.

Jump to another article in this series.