Raspberry Pi and General-Purpose Input/Output (2024)

A standard interface for connecting a single-board computer or microprocessor to other components is through General-Purpose Input/Output (GPIO) pins.

Robots are able to sense and interact with the environment through a wide range of components.

So that a robot can make decisions and perform actions, it uses a processor to receive information from and send signals back to the other components.

A standard interface for connecting a single-board computer or microprocessor to other components is through General-Purpose Input/Output (GPIO) pins.

Controlling robots using the Raspberry Pi

Want to keep learning?This content is taken from Raspberry Pi Foundation online course, Robotics With Raspberry Pi: Build and Program Your First Robot BuggyView Course

Raspberry Pi computers are wonderfully diverse in what they can do. Among the many applications they can be used for, robotics is one of the most exciting and powerful.

Each model of the Raspberry Pi has a set of General-Purpose Input/Output (GPIO) pins along the top edge of the board. These can be used for connecting and communicating with all manner of electronic components, acting as a physical interface between the Raspberry Pi and the outside world. Using the pins, you can program the Raspberry Pi to switch components on and off (output), or receive data from sensors and switches (input).

Raspberry Pi models

Most models of the Raspberry Pi have a 40-pin header, as shown in the image above. Of the 40 pins, 26 are GPIO pins and the others are power or ground pins (plus two ID EEPROM pins, which you should not play with unless you know your stuff!). Any of the GPIO pins can be designated (in software) as an input or output pin and used for a wide range of purposes; whether it is turning on an LED, driving a motor, or sending data to another device, the possibilities are almost endless.

Early models of the Raspberry Pi A and B have a shorter header with 26 pins, as shown below.

Raspberry Pi and General-Purpose Input/Output (1)

The Raspberry Pi Zero models have unpopulated pins (apart from the Raspberry Pi Zero WH) so there are holes where the GPIO header is located instead of physical pins. This means you need to add a header that includes the pins yourself.

Raspberry Pi and General-Purpose Input/Output (2)

Although it is possible to create a robot buggy with most models of Raspberry Pi, I recommend using a Raspberry Pi 3B, 3B+, or 4. These models allow you to program the Raspberry Pi easily and connect it to another computer or even a smartphone by using the inbuilt WiFi or Bluetooth, rather than needing to plug the Pi physically into a screen or a keyboard and mouse.

GPIO pin numbering

When programming the GPIO pins, there are two different ways to refer to them: GPIO numbering and physical numbering. Throughout this course (and in all our resources) we will refer to the pins using the GPIO numbering scheme. These are the GPIO pins as the computer sees them.

Raspberry Pi and General-Purpose Input/Output (3)

The numbering of the GPIO pins is not in numerical order, instead relating to the numbering on the CPU of the Raspberry Pi, so there is no easy way to remember them. However, you can use a reference board that fits over the pins, a printed reference (like the image above), or a website guide to the GPIO pins to help you.

Voltages

The voltage of a pin is labelled on the reference guide. There are two 5V pins and two 3V3 pins, as well as a number of ground pins (0V), which are unconfigurable. The remaining pins are all general-purpose 3V3 pins, meaning that the outputs are set to 3.3 volts and the inputs are tolerant of 3.3 volts.

A GPIO pin designated as an output pin can be set to high (3.3V) or low (0V). Components are usually attached so that setting the output to high will allow current to flow to them, while setting the output to low won’t.

A GPIO pin that is designated as an input will allow a signal to be received by the Raspberry Pi. The threshold between a high and a low signal is around 1.8V. A voltage between 1.8V and 3.3V will be read by the Raspberry Pi as high; anything lower than 1.8V will be read as low. Do not allow an input voltage above 3.3V, or else you will fry your Pi!

A word of caution

While connecting most components to the GPIO pins is perfectly safe, it’s important to be careful how you wire things up, or you could damage the Raspberry Pi or the components.

A few pieces of general advice:

  • Do not attach 3V3 components directly to a 5V pin on the Raspberry Pi, or you may damage the component or your device
  • Certain components, such as LEDs, should have resistors to limit the current passing through them
  • Do not connect motors directly to the GPIO pins; instead, use a motor controller board or an H-bridge circuit

In the next step, you will look at how to connect the motors to the motor controller board.

Want to keep learning?This content is taken from Raspberry Pi Foundation online courseRobotics With Raspberry Pi: Build and Program Your First Robot BuggyView Course
Raspberry Pi and General-Purpose Input/Output (2024)

FAQs

Raspberry Pi and General-Purpose Input/Output? ›

GPIO stands for General-Purpose Input/Output. These pins are a physical interface between the Raspberry Pi and the outside world. At the simplest level, you can think of them as switches that you can turn on or off (input) or that the Pi can turn on or off (output).

What is the input and output of A Raspberry Pi? ›

GPIO stands for General Purpose Input Output. The Raspberry Pi has two rows of GPIO pins, which are connections between the Raspberry Pi, and the real world. Output pins are like switches that the Raspberry Pi can turn on or off (like turning on/off a LED light). But it can also send a signal to another device.

What are general purpose input and output GPIO pins? ›

A general-purpose input/output (GPIO) is an uncommitted digital signal pin on an integrated circuit or electronic circuit (e.g. MCUs/MPUs) board which may be used as an input or output, or both, and is controllable by software. GPIOs have no predefined purpose and are unused by default.

Can Raspberry Pi be used as A general purpose computer? ›

The Raspberry Pi's operating system has always included many of the tools you'd need to take a crack at this, including a lightweight desktop environment and a couple of web browser options, and the Pi 4-based Pi 400 variant has always been pitched specifically as a general-purpose computer.

What is serial general purpose input output? ›

Serial General Purpose Input Output (SGPIO) is a method to serialize general purpose IO signals. SGPIO defines the communication between an initiator (e.g. a host bus adapter) and a target (e.g. a backplane holding disk drives).

What are the outputs of A Raspberry Pi? ›

There are two 5V pins and two 3V3 pins, as well as a number of ground pins (0V), which are unconfigurable. The remaining pins are all general-purpose 3V3 pins, meaning that the outputs are set to 3.3 volts and the inputs are tolerant of 3.3 volts.

What is the current output of A Raspberry Pi? ›

General Purpose Input Output (GPIO) Pins

The operating voltage of the GPIO pins is 3.3v with a maximum current draw of 16mA. This means that we can safely power one or two LEDs (Light Emitting Diodes) from a single GPIO pin, via a resistor (see resistor color codes).

What are general purpose input output pins in Raspberry Pi? ›

GPIO is an acronym for General Purpose Input/Output. A Raspberry Pi has 26 GPIO pins. These allow you to send and receive on/off signals to and from electronic components such as LEDs, motors, and buttons.

What is the difference between GPI and GPO? ›

GPI outputs (GPOs) are located in a separate tab and marked by a green arrow. The difference between a GPI and a GPO is that a GPI does not contain a logic, but merely serves as trigger for a GPO.

How many general purpose inputs does a GPIO 1 have? ›

The GPIO-1 provides sixteen general purpose inputs and sixteen general purpose outputs to control various aspects of a Vocia system.

Do I really need a Raspberry Pi? ›

There are a lot of things that a Pi is excellent for learning, especially if you are going to do embedded programming, EE, or similar hardware related stuff. However, there are plenty of things you don't need a Pi to learn. If you just want to do web and phone apps or game programming, you don't need a Pi.

Can you use a Raspberry Pi without an OS? ›

You don't want to use raspberry pi without an OS. If you do that, you would need to write some very complex drivers, especially the USB driver. You are better off just changing your app to use the Linux kernel directly. The Linux kernel is dead simple and super light.

What is general purpose input output in Arduino? ›

The GPIO is commonly used to write and read the pin state. GPIO stands to General Purpose Input Output, and is responsible to control or read the state of a specific pin in the digital world. For example, this peripheral is widely used to create the LED blinking or to read a simple button.

What is general purpose input output pins in microcontroller? ›

A GPIO pin is a generic pin whose value consists of one of two voltage settings (high or low) and whose behavior can be programmed through software. A GPIO port is a platform-defined grouping of GPIO pins (often 4 or more pins).

Is a serial port input or output? ›

As such, the serial port is mostly used for input/output with more distant parties, for which connection using a large number of signal lines is unsuitable. Data input/output using the serial port is often referred to as "communication", with input being referred to as "reception" and output "transmission".

What is the digital input of A Raspberry Pi? ›

To configure a pin as a digital input, pass an DigitalInput value to configurePin . This example configures pin 4 as an input. To read the value of a digital pin, use readDigitalPin . This example shows that a wire connected to pin 4 has an elevated voltage, which produces a logical value of 1 (true).

What is the input power of Raspberry Pi 4? ›

Like other electronic devices, the Raspberry Pi 4 board requires constant access to electricity with the right parameters. The latest model of the RPi is powered via a USB C connector, and the optimal power supply parameters are 5 V and a current capacity of at least 3 A.

What is the output of Raspberry Pi display port? ›

The Raspberry Pi Touch Display is an LCD display that connects to the Raspberry Pi using the DSI connector. You can use both the Touch Display and an HDMI display output at the same time.

What are the outputs of Raspberry Pi 2? ›

Specification
  • 100 Base Ethernet.
  • 4 USB ports.
  • 40 GPIO pins.
  • Full HDMI® port.
  • Combined 3.5mm audio jack and composite video.
  • Camera interface (CSI)
  • Display interface (DSI)
  • Micro SD card slot.

Top Articles
Latest Posts
Article information

Author: Terence Hammes MD

Last Updated:

Views: 6356

Rating: 4.9 / 5 (69 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Terence Hammes MD

Birthday: 1992-04-11

Address: Suite 408 9446 Mercy Mews, West Roxie, CT 04904

Phone: +50312511349175

Job: Product Consulting Liaison

Hobby: Jogging, Motor sports, Nordic skating, Jigsaw puzzles, Bird watching, Nordic skating, Sculpting

Introduction: My name is Terence Hammes MD, I am a inexpensive, energetic, jolly, faithful, cheerful, proud, rich person who loves writing and wants to share my knowledge and understanding with you.