Raspberry Pi GPIO - Getting Started with gpiozero

  Переглядів 428,521

DroneBot Workshop

DroneBot Workshop

День тому

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: dronebotworkshop.com/raspberr...
More articles and tutorials: dronebotworkshop.com
Join the conversation on the forum: forum.dronebotworkshop.com
Subscribe to the newsletter and stay in touch: dronebotworkshop.com/subscribe/
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!

КОМЕНТАРІ: 238
@sophianekhalfouni5004
@sophianekhalfouni5004 Рік тому
I just wanted to express my gratitude for the quality of your courses. You are doing an excellent job, sir! Please keep doing well. Thanks again. 😊
@scottburfoot3930
@scottburfoot3930 3 роки тому
Dronebot, you inspire me to learn this stuff in the best way possible. So detailed, yet so precise with only the most important information displayed. Cant wait to see you introduce openCV to the 5dof robot arm
@larrygj4764
@larrygj4764 3 роки тому
Thank you for such thoroughness and clarity. Much useful stuff packed in here!
@raymondmichael4987
@raymondmichael4987 4 роки тому
I really like how do your presentation, very impressive. I'm going full on Raspberry Pi now; keep them coming. Greetings from Tanzania 🇹🇿
@brebre3582
@brebre3582 3 роки тому
Loved your video instantly sir. One of the best explanations of Pi anywhere on the Internet. You have the pace and patience of a seasoned teacher. Kudos to you and thank you. Subscribe done!
@norbertbans
@norbertbans 3 роки тому
Cool, I like the small scene at the end with the mixed up PI‘s!!! Keep doing more of those well explained clips!
@bawadanieldangema1146
@bawadanieldangema1146 7 місяців тому
You make learning embedded systems so easy and fun. Thank you Sir 😊
@soky157
@soky157 4 роки тому
You make everything so clear and easy to understand. Thank you.
@shingabiss
@shingabiss Рік тому
in my opinion, your have THE BEST videos! Delivery pace perfect, clarity perfect, friendliness perfect!
@rondlh20
@rondlh20 4 роки тому
Amazing job again, very interesting and educational
@ShuMO99
@ShuMO99 3 роки тому
that was awesome. I really needed this level of information fed at this pace. Looking forward to watching many more. thank you!
@chuckmuckamuck8001
@chuckmuckamuck8001 3 роки тому
I've recently taken up this hobby and this my new favorite channel. Thanks!
@dave-in-nj9393
@dave-in-nj9393 4 роки тому
This is a good video and you cover things in detail. Since it is a RPi video, it is focused on that and you do a good job.
@AnthonyFournier
@AnthonyFournier 2 роки тому
I'd love more content like this. You have such a wonderful way of explaining things, I'd watch tutorial's of any kind.
@victorkarthik8135
@victorkarthik8135 2 роки тому
Great job providing all I need to get start with Raspberry Pi. It was nice comparison with Arduino. It gives a good understanding between microcontroller and Single Board Computer. Keep up the good work. Thanks!
@ggattsr
@ggattsr 4 роки тому
Best video comparison on the features and functionally of the Pi and Arduino that I have found on UKposts. Thanks for the info.
@paullee107
@paullee107 3 роки тому
I commented earlier; sir, you have THE BEST Arduino & RPi videos for beginner & intermediate users -- The best channel, that I will support and market. TY!
@JakeThomasCreative
@JakeThomasCreative 3 роки тому
Detailed yet engaging! Thank you once again.
@NewAgeDIY
@NewAgeDIY 4 роки тому
Great video today! Can’t wait until the next one. You will of course need to update your shopping channel and add a “ I love my Raspberry Pi” T-shirt😘
@paulaxford6754
@paulaxford6754 4 роки тому
Great video! Even with Arduino and Python experience I learned a lot from that, specifically that GPIO can be shared among Python programs.
@petermolnar6017
@petermolnar6017 2 роки тому
As always, clear and to the point! Thank you for sharing this!
@ar.mamunhossain9592
@ar.mamunhossain9592 4 роки тому
Great!. Thank you sir!. We are expecting more video on this topic.
@sampreechar5368
@sampreechar5368 3 роки тому
Wow, Awsome!!! very professional, VDO, Sound. Well put together. Thanks a million.
@antonnym214
@antonnym214 4 роки тому
Outstanding video! Very interesting and informative. I really like your relaxed tone. Super easy-going, which is great. I have a Pi 2B and not doing much with it. just wrote a few programs to the display. more or less a screensaver, but have my eye on a new Pi4 (maybe for my birthday) so I can enjoy it with wifi. That model really impresses me, because it's virtually a desktop computer replacement. All good wishes, sir!
@BigDogMoya1
@BigDogMoya1 3 роки тому
Thank you so much! You're an amazing teacher.
@abegafouda9136
@abegafouda9136 2 роки тому
Hé hé ! Incredible! God-sent man! You are answering all the questions I have in mind! I have been offered a Raspberry Pi 4 by my only real friend in the world. Bought yesterday, not yet sent. Am in Cameroon, he is in Europe... And the 1st video as I open UKposts is this one, created by whom? You, one of the best, with clear, concise, comprehensive explanations ever. Thank you.
@davekendall4698
@davekendall4698 4 роки тому
Great video. I have been wondering what to choose for a stand alone logger for my costly heating system. i have (4 zones + boiler) for on / off times to display on grafts so which is on longer ( not hotter) & then maybe then show temperatures for (send & return of boiler water). I think it would be a very useful project for many people to used. Thank you again
@Meine_Rede
@Meine_Rede Рік тому
This is perfectly explained. Short and clear! Thanks a bunch.😄
@grand.pitcher
@grand.pitcher 4 роки тому
Fantastic, you did very useful and great job. Thank you so much!
@robertdouville74
@robertdouville74 4 роки тому
Loved it, thanks, very well done and informative!
@johannespralle6831
@johannespralle6831 3 роки тому
You are a great instructor. Thanks. Suggestion: Talking about Pi to Pi communication via SPI Bus and CAN Bus.
@Michael-1205
@Michael-1205 4 роки тому
Awesome, very concise and easy to watch presentation. I thought Python was something to be afraid of but your presentation has just changed my mind. Thank you!
@idris7464
@idris7464 2 роки тому
Micheal python is easy it is not C++😁
@kingofhavila9850
@kingofhavila9850 2 роки тому
@@idris7464 I'm struggling to learn it 😪 😩
@davidlira8853
@davidlira8853 Рік тому
your back wall is so organized! awesome
@Perspectologist
@Perspectologist 4 роки тому
There are many different Arduino IDE compatible microcontrollers now. I was late to the Arduino world. I got started with the BASIC Stamp and their Javelin board. I bought one genuine Arduino Uno to help support their effort. It was much slower, less capable and more expensive than other options. I’ve rarely used it. I’ve mostly been using the ESP 8266, ESP32 and ATSAMD boards. The newer Arduino boards may help them to be more competitive. Certainly the Arduino Uno is a great tool for some things, I just mostly skipped over it due to when I got into this hobby. These days I’m also getting away from the Arduino IDE, and using Platform IO. I’m open to trying the new Arduino Pro IDE when it is further along. I need project settings.
@scotthiggins7804
@scotthiggins7804 4 роки тому
Great instructional video! Can you add some links for the bits and bobs that you used in this project?
@DavidVine-DOCVIDPRO
@DavidVine-DOCVIDPRO 3 роки тому
Wow! What a great workshop. Super organization too!
@ESwitchInc
@ESwitchInc 4 роки тому
Great stuff, once again! Would love to send you some switches to work with for your next video, let's talk!
@warrenscorner
@warrenscorner 4 роки тому
Of course they didn’t need to social distance themselves when you did this video. Thank you for the videos. Stay well!
@Boradumir
@Boradumir 4 роки тому
Very good information and even perfectly understandable for a not native speaker... One question about switches and raspberry pis... does the library you used automatically ignore keybouncing?
@Hitmonkey420
@Hitmonkey420 3 роки тому
What a workshop! Lookin pretty sharp, I'm jealous
@mandelbro777
@mandelbro777 4 роки тому
Wonderfully explanatory as usual. Great vid.
@goldenpacificmedia
@goldenpacificmedia 2 роки тому
Thank you for your terrific lesson and teaching.
@lollllloro
@lollllloro 4 роки тому
Hi! I believe there is a mistake on the slide at 3:48 A byte (B) usually means an octet [eight bits (b)] and computer memory and storage size is usually expressed in bytes instead of bits. As far as I know after searching online, the RAM and SRAM size units in the slide should have been [kB, MB, GB] instead of [kb, Mb, Gb] For example, the ATmega328 has 2 kB (16 kb) SRAM and 32 kB (256 kb) flash memory. The number etched on the top of SRAM and flash chips is usually in bits, though, and so are transfer speeds. I really like your videos, keep up the good work! :)
@abusultanfahad2789
@abusultanfahad2789 2 роки тому
Excellent simple clear explanation thanks.
@robertpendergast2620
@robertpendergast2620 4 роки тому
Clear and detailed. Thanks.
@EvileDik
@EvileDik 4 роки тому
Another great video, I've been wanting to graduate from attempting to blow up Arduinos to something more expensive for a while!
@bigsteve6729
@bigsteve6729 2 роки тому
Just got some new pi gear thought I'd pop back to the workshop to freshen up my knowledge after a nodemcu binge 😁
@havafazai9023
@havafazai9023 4 роки тому
Please make more tutorials. Best mechatronic teacher ever
@itsmmdoha
@itsmmdoha 2 роки тому
I thank you from the bottom of my heart ❤️ for making this video.
@PacocaAir
@PacocaAir 4 роки тому
Thanks !! Please make more videos about the subjects raspberry and jetson nano!
@bonganijele9770
@bonganijele9770 Рік тому
Nice content i like the way he talk's he's loud and clear. Fully explained in details.
@kandarpsoni7529
@kandarpsoni7529 3 роки тому
Awesome video. Simply brilliant. Thanks a Ton. 👍🏻
@MarkLawry
@MarkLawry Рік тому
It was a good reminder seeing you attached to an antistatic ground.
@cybersean3000
@cybersean3000 3 роки тому
Excellent tutorial. Thank you.
@levelmastersystems117
@levelmastersystems117 4 роки тому
Thank you very much, for this video.
@chrismoore9223
@chrismoore9223 4 роки тому
You’re the best. Thank you.
@karthikeyank3219
@karthikeyank3219 2 роки тому
Excellent!!! Really helpful for beginners
@peterashley6042
@peterashley6042 4 роки тому
Excellent video. Thank you.
@khun_le
@khun_le 4 роки тому
Awesome video. Thanks and keep up the great work.
@mursitkc5328
@mursitkc5328 3 роки тому
thanks a lot . i love your documenteries
@psudrat
@psudrat 3 роки тому
Thank you so much! Merci beaucoup!
@sugundanmm1160
@sugundanmm1160 Рік тому
Detailed explanation.I really enjoyed learning here
@jeremiahayres103
@jeremiahayres103 2 роки тому
You are awesome! This helped me a lot! Also I love the lab!
@hmdmddh
@hmdmddh 3 роки тому
Thank you very much for your well explained Videos
@EsotericArctos
@EsotericArctos 4 роки тому
Do you ever use the ESP8266 or ESP32 chips? They don't have quite so many GPIOs but they definitely have uses.
@myusernameisrighther
@myusernameisrighther 3 роки тому
I’d really like to know where I can get one of those multipurpose hubs. 3 usb AND wired network on one device? Awesome.
@usmanmehmood5224
@usmanmehmood5224 3 роки тому
Great video, can you please make a video of RFID sensor interface with rpi3
@Aridzonan13
@Aridzonan13 4 роки тому
Love your peg board.. Great intro. Have you done a PyFirmata project? I did notice you do have an I2C video. Do you have a preference and why? Just integrated my RasPi via PyFirmata to control an evap cooler. The RasPi allows me to record Analog values and display them via it's web server. Have recommended your channel to all of my RasPi contacts..
@billstrain1
@billstrain1 4 роки тому
Very good video. You are a good instructor.
@cheblack677
@cheblack677 8 місяців тому
It seems to me that you start the program from an editor like "Tommy" or something. What I need is to automatically run the program(python file) once the computer is booted. I'd like to have some interface, too. Some buttons on the screen(coding invisible behind) through which I can directly control IO pins.
@eduardovillar2211
@eduardovillar2211 3 роки тому
Thanks for video, that shows the unlimited capabilities of combine gpio with a computer, I guess it is the next steps learning after MCU is under control. Combined by displays, mqtt, cameras, HMI and so on possibilities are unlimited!! This is my first contact with Python and seems more compact language than Arduino C, interesting to keeping curious mind. Thanks again, hope to see more videos like that.
@ttheo3
@ttheo3 2 роки тому
Hey ! I love your channel and your videos ! I just wanted to correct a few things, arround 4:50, you says Raspberry needs a bunch load of USB devicesto get starting. I actually find it much easier to start than arduino. I just use for my PI : USB power supply, SD card. Having the computer connected to the wifi is really easy, and using SSH to get distant access is easy to. You just need a computeur to SSH into the pi, but you don't need USB devices to access and programm it. Wich for certain case it's easier than accessing the USB port of an arduino builted in the project. Anyway, thanks a lot fort the sharing of this very good video :D
@tomjoad1060
@tomjoad1060 Рік тому
Thank you for a well-made video!
@dav8485
@dav8485 3 роки тому
a great video, congratulations!
@cybergames33pl52
@cybergames33pl52 2 роки тому
so clear explained after bought i chosen good rasberypi but if i founded you before i could get easy explained my choice between rasbery and arduino i am begin of begin with exp programming so all understanded more easy with you yt channel
@hubercats
@hubercats 3 роки тому
Great video! Thank you.
@Sam-tg4ii
@Sam-tg4ii Рік тому
very clear. Thank you
@kajmolin297
@kajmolin297 3 роки тому
Interting! I have a Raspberry Pi 4B, but I can´t gett a current out of the usb port. I wounder if I had to connect the GPIO also?
@randomperson619
@randomperson619 4 роки тому
What is the blue band you are wearing, while explaining the Types of Raspberry boards? Is that ESD strap?
@ertan1147
@ertan1147 3 роки тому
it was very clear thank you. You could add also Windows 10 IoT and use c# to code :)
@desertbotio
@desertbotio 4 роки тому
Great videos. The Arduino MKR 1000 and 1010 WiFi - have WiFi in their name. Though a bit pricey. There is also a huge community that prefers the ESP32 related Arduino compatibles with their built in WiFi.
@eyal4
@eyal4 4 роки тому
great videos! Can you do maybe a video on how to program Arduino with Simulink? THANKS
@testbranding
@testbranding 4 роки тому
Amazing job it's educational too if possible 1000 thumbs up
@153SCORN
@153SCORN 3 роки тому
Used the PI & Arduino together. Best of both worlds.
@wallaceshackleton1889
@wallaceshackleton1889 4 роки тому
Great idea, although I've got to say that Unicorn poo is easier to buy than a Pi W.
@danieldefo7801
@danieldefo7801 2 роки тому
Great video! Thanks you!
@RottnRobbie
@RottnRobbie 4 роки тому
In a couple of the Python sketches, the code was in a While block. Great, and easy to relate to Arduino. But other Python examples have NO LOOP, and end with a call to pause (), with no mention of it or explanation of what it's for (except to say your pausing the program). Maybe it goes beyond your intended scope, but I really think you should've explained how the functions (objects) keep working, and don't just end! Anyone coming from an exclusively Arduino background won't have any idea of what's happening here.
@4STEVEJOY34
@4STEVEJOY34 4 роки тому
9:15 Do you have a link for $5 PI Zero? I only found $15.00. Love all your videos.
@anurasenarathna1703
@anurasenarathna1703 Рік тому
Great Video as Always.
@alexandrpetrov1110
@alexandrpetrov1110 3 роки тому
Thank you!
@rgdphome8974
@rgdphome8974 4 роки тому
👌 Gr8 as usual.
@farnoushbabaie7823
@farnoushbabaie7823 3 роки тому
Hi. Just saw your video on Lidar. I'm officially a fan now. Could you do one on Lidar on Pi? Please?:-)
@jacopo102
@jacopo102 Рік тому
I really liked this video it’s very instructive,but could you do this type of video for a rasberry pi 4?
@sansin-dev
@sansin-dev 3 роки тому
My project învolves collecting a lot of data from the sensors over the course of several hours. So would a Pi be more suitable for my application compared to Arduino? Also how are analog inputs handled? Thank you.
@sannyabacha4025
@sannyabacha4025 Рік тому
Brilliant!!!
@yudhobaskoro8033
@yudhobaskoro8033 3 роки тому
Can i use ubuntu mate on a pi4 for this project, and im curious to how can the GPIO only deliver 3.3v but there's an always on 5v that i use for fans
@khayalian
@khayalian 2 роки тому
Thank you very much, but i was wondering if there are tutorials with java. Thank.
@logovka9671
@logovka9671 3 роки тому
Super helpful!
@OctoomyYTOfficial
@OctoomyYTOfficial 3 роки тому
I actually use my pi for cable TV some times, since sometimes my nephews for some weird reason want to watch tv in my room.
@balkrishnawagle7205
@balkrishnawagle7205 2 роки тому
Sir You r a Great Thanks you Sir
Raspberry Pi 5: EVERYTHING you need to know
20:32
Jeff Geerling
Переглядів 1,1 млн
GPIO for any PC or Laptop: Adafruit FT232H
19:18
ExplainingComputers
Переглядів 193 тис.
Raspberry Pi LESSON 4 : Understanding and Using GPIO Pins
45:45
Paul McWhorter
Переглядів 48 тис.
Introduction to ESP32 - Getting Started
47:57
DroneBot Workshop
Переглядів 1,5 млн
Basic usage of the Raspberry Pi GPIO pins
13:44
Engineer Man
Переглядів 94 тис.
20 Food's You'll Never Buy Again After Knowing How They Are Made
29:02
10 Raspberry Pi Projects (All models, including Pico)
1:52:44
DroneBot Workshop
Переглядів 484 тис.
Raspberry Pi 4 Getting Started
24:54
Crosstalk Solutions
Переглядів 2,3 млн
How To Safely Connect a Breadboard to Raspberry Pi
11:21
M Heidenreich
Переглядів 28 тис.
13 Stunning Raspberry Pi Projects for 2024!!!
10:23
ToP Projects Compilation
Переглядів 150 тис.
I Can Save You Money! - Raspberry Pi Alternatives
15:04
Linus Tech Tips
Переглядів 3,2 млн
The Ultimate Guide to using Motors in Robotics (including ROS, Raspberry Pi)
25:56
Articulated Robotics
Переглядів 290 тис.
Слишком много порошка...
0:35
Это точно смешно
Переглядів 4,6 млн
Cosa Buena #brico #automobile #mecanico #coches #liquimoly
0:13
ModesTito
Переглядів 14 млн