Skip to content
Step by Step Internet 馃寪 Guides for learning to surf the Net

Raspberry Pi pins What are GPIO connectors and what are they for on my miniature computer?

One of the most useful points, and at the same time Most underrated of Raspberry Pi modules, are its GPIO pins, but By knowing how to use them, the possibilities are almost endless.

The GPIO ports are included in all Raspberry Pi models, although with differences in each. Its presence greatly expands the functionality of this versatile hob.

Useful for programming projects in Python and other languages, as for the inclusion of HATs in your Raspberry Pi model, knowing how to use these ports will allow you to squeeze the full potential of your mini computer, and right now we are going to explain everything you need to know to work with the GPIO pins like a pro.

What are Raspberry Pi pins and what are they for on my mini computer board?

Gpio utility on Raspberry

GPIO is the acronym for “General Purpose Input / Output”, and it’s basically a general purpose inlet and outlet system, presented as a series of ports on the Raspberry Pi board, and intended for various uses. These uses may vary depending on the project you have in mind, either as a simple patch board, to complex robotics projects.

Its main function is to make a connection between your Raspberry Pi and any device you need add for the development of a project, from an LED light, to much more complex purposes.

What are the main functions of the Raspberry Pi GPIO pins and how do they vary by model?

GPIO of a Raspberry computer

The GPIO pins on the Raspberry Pi give you capabilities similar to those that Arduino can have, since they elevate it from the status of a simple accessible mini-computer and allow you to receive connections for a wide variety of electronic projects. The different models of the Raspberry Pi have different number of GPIO connectors according to the version of each model.

The original versions of the Raspberry Pi included 26 pins displayed in 2×13 columns, which were actually designed to function as an input and output. Later models add a considerable expansion of the number of pins, increasing from 26 to 40 pins, among which we can find nine new GPIO pins. Compatibility is complete, because the function of the first 26 pins does not change at all.

The usefulness of the GPIO pins on the Raspberry Pi can be summarized as follows:

  • They have values output of writting and reading.
  • May read signals of absence or presence of voltage as binary data.
  • Are controllable by code, allowing you to raise or lower its voltage level.
  • GPIO pins are easy to configure individually for entry and exit.
  • They have a maximum voltage capacity that you should know to avoid altering its functionality.

Pin utility What can I connect and program with them on a Raspberry Pi single board?

Traffic light with a Raspberry

The great versatility of the Raspberry Pi is why there are a large number of add-ons designed to fit with it and extend its capabilities, these receive the acronym HATs (Hardware Attached on Top) and are intended to be attached to the Raspberry Pi through the GPIO ports. There are many, many developers who have designed a wide range of HATs to expand the functionality of the Pi, and these range from sensors, touchscreens and LCDs, to motors and audio devices.

Now, we present you a small list of HATs to start your way in the use of the GPIO ports:

  • Traffic hat: it integrates a set of LED lights that work with the GPIO pins that will allow you to learn their functions in a simple and basic way.
  • MotoZero: is a control module for direct current (DC) motors, very useful when integrating robotics projects to your Raspberry Pi.
  • SkyWriter Hat: is a gesture control panel for your Raspberry Pi designed to detect simple 3D gestures and positions. Easily controllable without peripherals using the Python API.
  • Piano Hat: It is a mini sound synthesizer with 16 piano keys and 18 sensitive buttons to start small musical projects.

Raspberry Pi pins vs Arduino pins How are these components different from both development boards?

Arduino pins

Raspberry Pi and Arduino are two products that essentially consist of a board that can be used as a base for all kinds of electronics and robotics projects, but These are two completely different products. Carrying out an exact comparison between both units is a complex task because they are two boards intended for very different purposes.. But they share a common attribute, and this is their great utility for electronics projects.

Both projects are very even with each other since both have their pros and cons. Arduino is specifically designed to be a base concept for almost any project, which has a large number of both analog and digital inputs for the installation of a wide variety of add-ons. Raspberry Pi, was designed as a mini computer, so while it is not as versatile in the electronics project field as Arduino, compensates for this lack with greater computing power.

A plus point for the Raspberry Pi is its native ability to connect to the internet via Wi-Fi or Ethernet cable. Although Arduino can integrate these capabilities through expansion boards, doing so would take care of part of their connections, plus spending a bit more to get the expansions.

On the other hand, Arduino has a dedicated software for electronics projects that executes the action programmed on the board when it is turned on, unlike Raspberry Pi, which requires the installation of an operating system to be able to carry out the actions we require, which ends up having a negative impact on many projects.

Raspberry Pi Pin Programming What languages ​​are used for programming when developing hardware with GPIOs?

The way of control the Raspberry Pi GPIO ports and use them to get the most out of your projects, it is through programming language. The versatility of the Raspberry Pi gives it compatibility to read a wide range of programming languages.

Here are the most used and useful when using the GPIO pins of your Pi:

Scratch

It is a language designed for the early teaching of programming languages. By being segmented into blocks, you have the facility to focus on the logic of the programming language without interfering with the usual morphology and syntax (periods, commas, hyphens, parentheses, etc.) Raspberry Pi OS includes a window with a variety of programming languages, among which is Scrath. All you have to do is follow the steps to install the extension and you can start programming the GPIO pins.

Python

It is one of the most used programming languages ​​today, is an interpreted language of dynamic type that allows programming a very wide variety of purposes for the GPIO ports. Python is one of the programming languages ​​included in the Raspberry Pi OS operating system, so most of the time it will be necessary to have it installed in order to start our project with GPIO.

C / C ++ / C #

Each of these programming languages ​​is an improved variant of the previous one and intended for a slightly different purpose:

  • C in a typed language medium level that allows to create softwares and applications of low / medium level.
  • C ++ was created as an extension to enhance the capabilities of the C language, making it a hybrid language, since it is oriented both to the creation of software and to the manipulation of objects.
  • C # (pronounced “C Sharp”) It is a standardized language that derives from the C / C ++ syntax and is oriented to the development of software on the .NET API, as well as to the handling of objects.

Although these three languages ​​are derived and have slightly different functions from each other, all are usable for programming the GPIO ports of the Raspberry Pi. Mastering the three languages ​​will allow you to expand its functions in practically unlimited ways.

Processing3

It is a programming and development language based on java and oriented to the development of audiovisual and multimedia projects, so it’s a great option for digital artists with relatively limited programming skills. Thus, they unleash their creativity through the use of add-ons programmable via the GPIO pins.

List of the best projects that you can do yourself with the pins of your Raspberry Pi.

Raspberri Pi 4

When you have the basic programming knowledge and you know the limitations of your Raspberry Pi, you can do the following projects:

LED alarm with Raspberry Pi

It consists of an LED light coupled to the GPIO pins of the Raspberry Pi that syncs with Google Calendar and issues notifications lights that function as a reminder for scheduled events. With the GPIO pins of the Raspberry Pi and a Unicorn HAT programmed and adapted with Python, you can make an alarm that is synchronized with your entire virtual calendar and prevent you from being late for a meeting again.

Motor controller

The Raspberry Pi board works as the perfect motherboard for the installation of a direct current motor that will serve for your electronics and robotics projects. With a few external components and a Python code, You can connect a DC motor to the GPIO pins of your Raspberry Pi and use it as a power supply. This project is particularly useful for understanding the electrical operation of the GPIO portsVery useful data for any project that requires using a Raspberry Pi module as a backplane.

Motion sensor for LED light

For this Proyect, We will use a passive infrared (PIR) motion sensor. This attachment attaches to the GPIO pins of the Raspberry Pi, and provides a sensitive detector that senses the heat of the human body in a range of six or seven meters. One of the most common companions of the PIR sensor is an LED light, which is also attached to the GPIOs and allows us to create a motion detection LED alarm.