Getting started with Raspberry Pi GPIO and Python

How to use the Raspberry Pi GPIO using gpiozero library.

Fernando Souza
Vacatronics
Published in
4 min readAug 25, 2020

--

Introduction

A Rasberry Pi (RPi) is a low cost mini computer and has the size of a credit card. It is a great solution for hobby and home projects (and some commercial, too) because it has various input/output pins, video, camera, sound interfaces and many good OSes to install.

One the main characteristics of a RPi is its GPIO pins. GPIO stands for General-Purpose Input/Output. These pins are the interface with the external world.

In a simple way, you can think them as switches that you can read the status (inputs) and lamps that you can turn on or off (outputs).

Layout

The Raspberry Pi contains 40 GPIO pins, distributed as the image below.

Raspberry Pi GPIO pins layout. Source.

As you can see, some inputs can also have other functions than just input or output.

  • GPIO: general input or output pin. The output level is 3.3V with 50mA max, so avoid using with a large load which can damage the pin and even the board. A LED, ok. A motor, don’t even think about it.
  • I2C (Inter-Integrated Circuit): it allows to connect with hardwares that support the I2C protocol.

--

--

Fernando Souza
Vacatronics

Enthusiast of programming, electronics, technology and beer, not necessarily in that order. BuyMeACoffee: buymeacoffee.com/ustropo