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

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 grew up in Brazil, and wrote his first program at the age of 10 using Logo. He moved on to programming in BASIC shortly thereafter, and by the time he was in High School he was coding in Pascal. When he started college in the US, he learned C, C++, Java and had several developer jobs programming with server-side languages for web development like: Coldfusion, Perl, Php, etc. He was introduced to...