Raspberry Pi GPIO – Getting Started with gpiozero

Learn to use the Raspberry Pi GPIO connector and the gpiozero library to interface with an LED and some switches. We’ll even make a very simple camera and have our Pi take a selfie!

Article with code samples: https://dbot.ws/rpgpio
More articles and tutorials: https://dronebotworkshop.com
Join the conversation on the forum: https://forum.dronebotworkshop.com
Subscribe to the newsletter and stay in touch: https://dbot.ws/dbnews

The GPIO (General Purpose Input/Output) is a 40-pin connector on every modern Raspberry Pi board that allows you to expand your Pi and connect it to external sensors, drivers and displays. And today we’ll start from scratch and see how easy it is to interface simple devices to the GPIO and control them with Python, using the gpiozero library.

When we need to interface with sensors, displays or motor drivers we generally use an Arduino, but there are several advantages to using a powerful microcomputer like a Raspberry Pi. With its increased processing power, large storage and memory and ability to interface with the Internet and Bluetooth it can add a new level of power to our projects.

The 10-dollar Raspberry Pi Zero W is a viable replacement for an Arduino board, and it’s the Raspberry Pi that I’ll be using in today’s demonstrations. In fact, everything I demo today could have easily been run on a 5-dollar Raspberry Pi Zero, as we don’t need the networking or Bluetooth capabilities.

We’ll keep it simple today and only interface with an LED and a couple of pushbutton switches. Just so you can get a good feel for how easy it is to code for the GPIO, thanks to the power of the gpiozero library.

To make it interesting the final demos will also use the Raspberry Pi Camera, and we’ll build a functional digital camera with only a few lines of code. Try that with an Arduino!

Here is the table of contents for this rather long video:

Pi vs Arduino – 1:45
Selecting a Raspberry Pi – 6:35
GPIO Prototyping Accessories – 10:28
Raspberry Pi GPIO – 15:41
gpiozero Library – 19:51
Hooking up to the GPIO – 21:23
Setting up the Raspberry Pi – 22:51
Blink Compare (Arduino vs Pi) – 25:00
LED and Button Experiments – 33:14
Hooking up the Camera Experiment – 40:17
Controlling the Camera – 41:20

While today’s demos are extremely simple they will pave the way to doing more complex things with the GPIO, and I’ll be doing that in future videos. Make sure you’re subscribed to the channel so that you don’t miss those!

And keep in mind that the Raspberry Pi GPIO has been unofficially adopted by many SBC (Single Board Computer) manufacturers, so learning to interface to the Pi will also open the doors to working with several other platforms.

BTW, for those who make it through this long video, there is a short “blooper” at the end!

Enjoy the video!

source

You might be interested in