Let's get physical: How to use GPIO pins on the Raspberry Pi

Let's get physical: How to use GPIO pins on the Raspberry Pi

The 10th article in our series on getting started with Raspberry Pi explains how the GPIO pins work.

A Raspberry Pi Zero
Image credits : 
Raspberry Pi Foundation, CC BY
x

Subscribe now

Get the highlights in your inbox every week.

Until now, this series has focused on the Raspberry Pi's software side, but today we'll get into the hardware. The availability of general-purpose input/output (GPIO) pins was one of the main features that interested me in the Pi when it first came out. GPIO allows you to programmatically interact with the physical world by attaching sensors, relays, and other types of circuitry to the Raspberry Pi.

Each pin on the board either has a predefined function or is designated as general purpose. Also, different Raspberry Pi models have either 26 or 40 pins for you to use at your discretion. Wikipedia has a good overview of each pin and its functionality.

You can do many things with the Pi's GPIO pins. I've written some other articles about using the GPIOs, including a trio of articles (Part I, Part II, and Part III) about controlling holiday lights with the Raspberry Pi while using open source software to pair the lights with music.

The Raspberry Pi community has done a great job in creating libraries in different programming languages, so you should be able to interact with the pins using C, Python, Scratch, and other languages.

Also, if you want the ultimate experience to interact with the physical world, pick up a Raspberry Pi Sense Hat. It is an affordable expansion board for the Pi that plugs into the GPIO pins so you can programmatically interact with LEDs, joysticks, and barometric pressure, temperature, humidity, gyroscope, accelerometer, and magnetometer sensors.

About the author

Anderson Silva - He was introduced to Linux by his uncle back in 1996. In the early 2000s Anderson transitioned from being a developer to a system administrator/release engineer. He joined Red Hat as a Release Engineer in IT. Since then he has had several roles at Red Hat. He currently holds an RHCE and an expired RHCA and is an active Fedora package maintainer.