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

GPIO for Raspberry Pi What is it, what is it for and what is its use in this mini computer?

Drafting projects is one of the reasons for being any Raspberry Pi. But in order to put them into practice, the GPIO pins of this device need to be put to good use. Each model brings connections with different characteristics and, to take advantage of them, it is essential to know them.

Successful use of pins GPIO It’s in learn how the programming system works and in properly connecting the components so as not to cause any damage to the board.

In this guide, we will go deep into different aspects related to these pins, taking a tour of the functions they perform in Raspberry models as well as we will recommend projects that can be developed in these single board computers.

What is GPIO for Raspberry Pi and what are these pins on my mini PC boards for?

GPIO of a Raspberry computer

GPIO stands for “General Purpose Input / Output” or translated into Spanish equals general purpose inputs and outputs. Once configured correctly, the pins are ready to perform different functions, not a specific one. On all Raspberry models are organized and distributed in the same way.

The pins are adapted to the needs of each project through the programming language. They are used to control electronic circuits, add peripherals in a convenient way and establish communication between these peripherals and the board. In a nutshell, makes the integration of the boards with external components less complex.

What are the main functions of the Raspberry Pi GPIOs depending on the model?

The number of pins on the Raspberry Pi has been increasing since the first version that had 26, until the current one that has 40, creating more options when designing a project. The good thing is that regardless of the version, they are all equally compatible with any project. Pins are in a row at the far right of the plate, and by not being populated they give the flexibility to use the connections that are necessary for the project.

Some of the functions that they can fulfill are the following:

  • Connect a device external.
  • Receive voltage signal incoming sent by the connected device and determine with the reading if it is high or low.
  • Send the signal voltage.
  • UART connection for serial ports and devices.
  • Modulate the pulse width.
  • GND connection or to land.
  • Communication for the SPI protocol for data synchronization.

GPIO pins utility What can I connect and program with them on a Raspberry Pi?

Gpio utility on Raspberry

The amount of external devices to be connected to the board depends largely on the project to be developed. In some cases, more components are required than in others, but the capacity of each microcomputer never ceases to amaze. Each project comes with clear and specific instructions where to make the connections, so that the user can understand this process regardless of the level of knowledge they have.

Regarding the connections, we must indicate that the following can be installed on the pins:

  • Energy supply 3.3V and 5V.
  • Digital inputs and outputs for connecting simple switches and sensors.
  • SPI devices Of high speed.
  • I2C components that allow communication between the connected chips.

On the other hand, at the programming level, with the operating system he is can assign various functions to the GPIO pins, since the Pi board is designed to work with physical programming.

Among the tasks that can be scheduled, we have:

  • Program the voltages of the inputs and outputs.
  • Automate pulse width modulation, which controls the energy that is sent to a load.
  • The information pass between the integrated circuits on the board.
  • The communication between integrated circuits and controllers.
  • And communication between the transmit pin and the receive pin.

GPIO vs Pins of an Arduino How are these electronic components different?

Arduino pins

At first glance, we would say that they are two quite similar plates, with both you can create various projects.

However, the differences begin to appear when we see more details of each:

  • Free software: in the case of Arduino, anyone can create their own versions of the board because the software is open, while in Raspberry they have control of creation and production.
  • Tickets– A strong point that the Arduino has is the combination of analog and digital inputs that are easily turned on and off with your system. For its part, the Raspberry was designed as a computer, it has greater computing power and new features are added in each version.
  • Connectivity: If we talk about the connection modes, the Raspberry has Wifi and Ethernet integrated while an Arduino has to be added a new board that increases costs and limits the number of ports.
  • System: Arduino directly executes scheduled tasks, while Raspberry needs the operating system to be full and takes a little longer to boot. This element affects the development of some electronic projects, since it takes more time to execute the functions, activate the ports and run the program.
  • Arduino is an easy-to-use micro controller, running small applications that control basic devices, and ideal for any electronic project. Raspberry was created more like a computer, ideal for implementing programs, acting as a server and for projects that require more complexity and multiple tasks.

Nevertheless, both applications are used by project developers all over the world, taking into account its characteristics and peculiarities.

Raspberry Pi GPIO Pin Programming What languages ​​are used to program any project?

Acquire the Programming skills are necessary when working on electronic projects. Fortunately, for Raspberry Pi there are several simple tools that allow you to schedule tasks.

Here are four programming languages ​​you can use:

Scratch

This language allows learn to program without being an expert in handling codes. And although the online version could be used, it is better to make the installed version so as not to lose the advantages of GPIO.

Therefore, once you download and install the program, you use it like this:

  • Enter the Raspberry menu, click on “Programming“And then select”Scratch”.
  • There the application will open and a valid recommendation is set the language.
  • In the block menu, select the option “Add an extension”To use the pins GPIO.
  • Choose the option “PI GPIO” and on the right side press Okay”.
  • Already with these options activated, you can put an input and output pin with the possibility of activate it and disable it. In addition, the team is ready to perform any task assigned to it..

Python

This language is one of the most used in the whole world in order to create applications and automate operations. The philosophy is that anyone with basic programming knowledge can use it and benefit from the advantages it has. It should be noted that It is installed by default in the Raspberry PI OS operating system, that’s an advantage because you won’t have to install anything extra.

To use it, follow these steps:

  • Inside the device, we go to the section “Menu- Programming”.
  • Once you show us the options, select the version you should use.
  • The “Pyhton Shell tab”. From that moment on, we will be able to write and execute commands, seeing the results instantly.
  • Every time the “>>>” symbol appears it is giving us the option to enter commands.

C / C ++ / C #

The C language is used to create systems and also applications. It could be classified as medium level, although it also has low-level characteristics. On your side, C ++ is a hybrid language and multiparadigm to which aspects of generic programming have been added. Finally, C # derives from the previous two, has some similarities to java but with improvements. It is designed to generate programs on itself.

Processing3

This language is developed based on Java and It is useful for the production of digital multimedia elements. It is Open Source and its use is very easy.

List of the best projects you can do with the GPIO pins of your Raspberry Pi

Traffic light with a Raspberry

The time has come to innovate and invent. We have chosen three interesting projects that have been shared and that can be developed by anyone. It applies both to the most advanced users, as well as to children with little programming knowledge. What is most required is the desire to learn.

Read carefully which are the projects:

Simple traffic light

We are going to program a conventional traffic light using the PYthon application, As I told you above, it comes installed on the Pi.

The steps are the following:

  • Import the libraries to use.
  • After, we declare the type of pin.
  • We create a loop and then deactivate and activate the pins connected to the LED. In the end we build the traffic light on the basis of the prototype and connect it to the card.

The materials needed for this operation are the following:

  • 4 hoses.
  • 3 resistors.
  • 3 LEDs.
  • 1 breadboard.

LED lights

This simple project is based on make a little circuit with a pair of LED lights and control one of them with command lines through our Raspberry Pi. This light will blink with the intermediate frequency of one second.

To achieve this, we must take the following steps:

  • Open Python and create a new file to save the programming code.
  • In the front line, import the GPIO pin libraries that will allow us to take control.
  • Next, we choose the way we are going to go to the pin, if by the plate or by the chip. Once we decide, we start the pin and are controlled with the options “True” or “False”.
  • In the end, a tab will show us how the final schedule was and we give “Keep“.

To achieve the objective, it is necessary that we have the following elements at hand:

  • 1 resistance 100Ω.
  • 2 hoses.
  • 1 breadboard.
  • 1 LED diode (5mm).

Security system

Doing this programming with your Raspberry board is not complicated. This system scans your home environment and makes a notification to your phone. It also alerts you when it is disconnected for any reason. The base of this project is a Raspberry Pi 3.