Raspberry Pi GPIO -...
 
Notifications
Clear all

Raspberry Pi GPIO - Getting Started with gpiozero

1 Posts
1 Users
0 Likes
951 Views
DroneBot Workshop
(@dronebot-workshop)
Noble Member Admin
Joined: 4 years ago
Posts: 1174
Topic starter  

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

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:

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

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!

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
Quote