Raspberry Pi Linux LESSON 26: Controlling the Raspberry Pi GPIO pins from Python

  Рет қаралды 91,927

Paul McWhorter

Paul McWhorter

Күн бұрын

Пікірлер: 126
@zynoda
@zynoda 9 жыл бұрын
This is the best video series on the internet for programming the Raspberry Pi.
@johnlayman2836
@johnlayman2836 6 жыл бұрын
I really appreciate how you explain the code you use rather than just throwing out a script and saying "Here you go". I'm trying to learn the code, not just make a servo work. Many thanks.
@stigmellem
@stigmellem 7 жыл бұрын
After learning myself to program the Vic-20 as a 15 year old in 1985 as a hobby, I began studying humanistic subjects. When I was 30, a former girlfriend bought me Lego robotics. Now I'm 47 years old and your lectures helps me pick up my real interests again. It's so much fun. Thank you :) (Seems like I was the only one not realising my true interest :D ).
@WayneRigley
@WayneRigley 6 жыл бұрын
after searching online for "MY" kind of teaching i found your channel ! so thank you first off.. tonight ill start at lesson 1 and work up to this. been a Pi user for a while but only with MagicMirror stuff, this is my first time on the GPi0 side of things. have a zero and 3B+ not sure what im using yet, but i have a 4 chan realy that needs setup with a few things. project is for the chicken coop. chan 1 - operating the linear actuator ( has limit stops ) to open the chicken door at a preset time int he morning and then chan-2 closes the door, chan 3- led lighting in the coop chan 4- 12 volt fan. future config for the pi i have a set of temp sensors that i want to see inside temp outside temp and water temp in the coop... glad to be a part of your channel !
@paulmcwhorter
@paulmcwhorter 6 жыл бұрын
Thank you for the kind words, and I too am a backyard chicken enthusiast. We have about 30 chickens, and would love to have an automated coop that could be left unattended for months on end. Hence, we would need in addition to the above some sort of auto feeder, and we would need auto watering, and then maybe a video system so we could periodically check in. Love having chickens, but sort of ties you down, and makes vacation hard as you have to find a chicken sitter.
@bobert13581
@bobert13581 8 жыл бұрын
You have fabulous teaching skills, thanks for putting these online.
@blusapphirervg
@blusapphirervg 8 жыл бұрын
Amazing work with this video. Your pacing and thoroughness makes it very easy to learn. I've been working with Linux and Python for a short time and have thus far been slightly confused. Not anymore. Thanks a bunch. Great work!!
@daveb-bx1hh
@daveb-bx1hh Жыл бұрын
Thank you Paul for your contributions! And Happy NEW YEAR! as soon as I figure out how I want to utilize ansible (based upon python) to control GPIO - and yes I realize just because you can do something doesn't mean you should...
@bocephus3699
@bocephus3699 5 жыл бұрын
@14:47 "I actually practice this stuff before I come on here so I know I make sure what I'm doing...." takes a drink of a rum and coke.
@dolfinmagikpro
@dolfinmagikpro 3 жыл бұрын
Wonderful lesson. Thank you! One suggestion ... I know that, for the most part, people will be using brand new, or uncut, LEDs, in which case, saying that the "long" lead is the positive (anode) lead. However, that wouldn't work if they are using a used one, scrapped one, one where the leads have been cut. So what I do is tell people to look at the contacts INSIDE the LED. One of them looks like a pointer, or "arrow" (the Cathode) and the other one looks like a post or straight block (the Anode) if you will. I tell people that "the arrow points to positive." Just thought I would share that. Keep up the great work! As always ... Have a better day!
@benmiddleton8775
@benmiddleton8775 5 жыл бұрын
Brilliant thank you! after frying my first raspberry pi in less than 24 hours things are finally starting to make sense!
@Berserk8Ilidan
@Berserk8Ilidan 8 жыл бұрын
You are an excellent teacher, thanks a lot for the lessons!
@emersonbaik8193
@emersonbaik8193 Жыл бұрын
I can't wait to finish this series and begin your Beagle Bone one! :) You are amazing!
@dannymeadows5448
@dannymeadows5448 6 жыл бұрын
These lessons are just Fantastic to learn linux plus the ability to control sensors just can't say enough.
@amaklp
@amaklp 7 жыл бұрын
I wish we had more teachers like you! Excellent videos!
@eanan348
@eanan348 4 жыл бұрын
Excellent demonstration and examples.
@seangleason7298
@seangleason7298 8 жыл бұрын
This was super helpful. Thank you very much. Sincerely - probably the best youtube tutorial I've ever done.
@justforphysics4584
@justforphysics4584 5 жыл бұрын
You are so brilliant Teacher and a Programmer, keep making videos and God bless!
@bluesquare23
@bluesquare23 7 жыл бұрын
I appreciate all the work that went into these videos. I feel like I've learned a lot!
@gmmotzu
@gmmotzu 8 жыл бұрын
Hi Paul! Very informative! I've been searching for a great tutorial on Raspberry and i found your channel, which is amazing! You're doing a great job! Thank you so much for your effort!
@Deepakkumar-tq1xv
@Deepakkumar-tq1xv 8 жыл бұрын
i loved the happy way of your teaching ...enjoying every little or big thing
@farukhannan9240
@farukhannan9240 8 жыл бұрын
Your tutorials are really great. i learned a lot watching your tutorial. keep on the good work. thank you paul.
@lovemyjob57
@lovemyjob57 7 жыл бұрын
Paul ... You do a great job teaching this lesson Thank you
@erygion
@erygion 5 жыл бұрын
Great lesson Mr. Mcwhorter. I was itching to learn some python. Thank you sir.
@bbarcus3002
@bbarcus3002 7 жыл бұрын
This stuff is great Paul, I love your lessons!
@ricardobjorkeheim775
@ricardobjorkeheim775 3 жыл бұрын
Great lesson Paul, So is the same as in the Jetson Nano. Perfect!!! :)
@ramyaanand17
@ramyaanand17 5 жыл бұрын
I like your teaching, Professor. It is very interesting.
@jameshyde6395
@jameshyde6395 8 жыл бұрын
Great video series Paul. i'm keeping up so far.
@johncraft9464
@johncraft9464 7 жыл бұрын
Excellent teaching skilz, as the first 25 were, great job and thanks a lot
@HamidAkerman
@HamidAkerman 9 жыл бұрын
Great, well designed, and well presented Series on Arduino and Raspberry Pi. Learning a lot and Enjoying so much. Thank you and Thumbs Up!
@paulmcwhorter
@paulmcwhorter 9 жыл бұрын
Hamid Akerman Thanks for the kind words!
@fabianzhang-phattruong4573
@fabianzhang-phattruong4573 5 жыл бұрын
excellent skill, enthusiastic teaching !!! thank you so much
@binder098
@binder098 2 жыл бұрын
Here' a comment, thanks, Paul. I am hanging in here, Frankie from New Orleans.
@JoeEvansSound
@JoeEvansSound 8 жыл бұрын
Very good and informative - put across in an intelligent and appreciative manor. VG 10/10 Thank you for your hard work in these videos. Much much appreciated. pj
@sivakumar_svn
@sivakumar_svn 9 жыл бұрын
it so cool all d classes i find more here and learn lot
@jdf026
@jdf026 9 жыл бұрын
I did the assignment at the end of this assignment. It took a lot of effort using nested if/else if statements and I was disappointed because I was looking forward to seeing you do it in a simpler way on the next video. I did not get to get my assignment checked :-(
@kientran424
@kientran424 7 жыл бұрын
Thanks a lot for the tutorials ! I viewed your arduino lessons too, you are awesome
@spiworkshop9416
@spiworkshop9416 5 жыл бұрын
excellent demonstration .
@heng4210
@heng4210 8 жыл бұрын
great video and thanks for teaching.i learn following your video.Thank You.
@gerzy100
@gerzy100 8 жыл бұрын
Boom !! Led is On :)
@nelsondarwinpaktech3954
@nelsondarwinpaktech3954 6 жыл бұрын
Good,,,every good effort must be appreciated...
@haowang9515
@haowang9515 9 жыл бұрын
really great lessons
@jackiedaciafouts1018
@jackiedaciafouts1018 Жыл бұрын
Paul, I am a novice at RPI's but did use them on a couple projects. I wished I would have found your website before I done them. Would have saved me a ton of time and head scratching. Both project, I use pushbutton inputs but no physical outputs. I just use Python command and not Sudo Python and they both work. I'm wondering if you only need Sudo for output commands?
@h2o-fpv623
@h2o-fpv623 6 жыл бұрын
thank u so much im not a jung person but im learning with u.again thank u.
@rolandogonzalez3151
@rolandogonzalez3151 9 жыл бұрын
Hey! Cool video. I learned the difference between board and BCM setup: physical vs GPIO pin numbering. My goal is actually to code in Visual Studio for the Win 10 IoT but I'm not finding much GPIO info on that.
@edward346011
@edward346011 7 жыл бұрын
Absolutely love your videos and you talking about dogs. Don't let my picture disturb you I put an app on the app store called Z Rage thats where that is from. I wish you would go more into robotics. Thats where my interest rest or give recommend some good sources to get more information. Thanks once again for passing on your knowledge !!!!!
@stevelawson8077
@stevelawson8077 9 жыл бұрын
Great lesson!
@keneflucas937
@keneflucas937 3 жыл бұрын
Hello Paul. I am happy & excited about the learning experience that you are providing. I am very new to writing code. I'm hoping you can give me a better understanding of one part at the end. The.......blink_num.... for i in......command(s) the number of times it blinks is equal to the users input (user's answer to the question)? What is the "i" in the 'for' statement? I'm assuming in range means numerical order from 0 to the user's input. Is that correct or somewhat close. Thank you.
@butsy1986
@butsy1986 9 жыл бұрын
nice lessons they are very clear, I program in c I was curious :) nice job
@21cgd
@21cgd 8 жыл бұрын
Hi Paul I noticed to terminals labeled "run" on the raspberry pi 3. Is it possible to add a power/shutdown button there and what would the code possibly? I am having a hard time locating information on this. Thanks Chris
@agentrfr1
@agentrfr1 9 жыл бұрын
Hi Paul Just a comment - when controlling the GPIO pins on the pi specifically using python, it is normally a good idea to rather put the GPIO code within its own function as well as to contain a try/finally statement so that it can perform a cleanup() even if there is a keyboard interrupt or a crash in the GPIO function :) Otherwise in this case if you do a keyboard interrupt with the LED on, it stays on even after you close the python daemon - could be a problem if you were doing something like switching a logic level MOSFET or closing a relay through a BJT
@paulmcwhorter
@paulmcwhorter 9 жыл бұрын
+Agentrfr I agree with what you are saying. It is just as we go through this series of lessons, I have not taught functions yet, so people taking them in order would not know how to do that. In these lessons I try to get to pin control as soon as I can, so did not get into python functions.
@agentrfr1
@agentrfr1 9 жыл бұрын
I'm happy with that and I think what you are putting together is a great beginner's guide - but you may want to for further videos do a GPIO.cleanup() at the start of each program just in case :) (otherwise someone somewhere is going to have a light-bulb they can't turn off)
@tangenikamati5799
@tangenikamati5799 9 жыл бұрын
+Agentrfr This is very true. GPIO.cleanup is very crucial and need to be included in any program pertaining GPIO. Just for good program behavior.
@louismefor9539
@louismefor9539 4 жыл бұрын
this is awsome had to order my iot kits, and was able to do this
@MaheshSharma-yp6wr
@MaheshSharma-yp6wr 7 жыл бұрын
hey paul...don't you think there must be int(input("Enter the no of blinks or whatever")) must be there in your 6th line of python file that you created? As default input is character and a for loop cannot judge for character range if started from 0 i.e it is meaning less ( for i in range(0,a charcter))? please answer me quickly..
@charlesbr4644
@charlesbr4644 8 жыл бұрын
Hi Paul, Excellent tutorials!!! Can you please make a relay tutorial? If you already posted one, can you please post the url? Thank you!
@hanx3926
@hanx3926 4 жыл бұрын
GOOD TOTURIAL!
@mammabouaouich3532
@mammabouaouich3532 8 жыл бұрын
plz i want to make communication beetwen a server wamp in my computer and raspberry how i can do that???
@th3h01lo
@th3h01lo 4 жыл бұрын
Hey Paul, I'm slowly working through your lessons and will be moving onto you other content when I'm done here. I hit my first issue this lesson with the following error message coming up, "Traceback (most recent call last): File "blink.py", line 7, in for i in range(0,blink_num): TypeError: 'str' object cannot be intemperate as an integer" I will have a look online to see if I can find a solution but would appreciate your input. Cheers.
@th3h01lo
@th3h01lo 4 жыл бұрын
Found a solution and added below. 7>> for i in range(0,int(blink_num)): Cheers for the content Paul, very enjoyable and a nice chilled pace.
@charlesbrewer6552
@charlesbrewer6552 9 жыл бұрын
I was thinking, wouldn't be good practice to run "clean up" as part of anititialisation, before allocating the pins in case someone had not run it at the end of the previous program?
@paulmcwhorter
@paulmcwhorter 9 жыл бұрын
+Charles Brewer Probably a good thing you suggest.
@lightning_sree2531
@lightning_sree2531 4 жыл бұрын
hey @paul. I have tried to run the blink.py by just "python blink.py" & it worked..!!!.Moreover, I think due to the python (software) or raspi has updated. There are some syntax, which got some updates.. hence, your video also need to get some upgrades.....
@strictlyforcomments
@strictlyforcomments 5 жыл бұрын
Very helpful, Thank you!
@jimmyers47
@jimmyers47 4 жыл бұрын
Thanks - I am surprised you did not import time library
@aimeiz1
@aimeiz1 7 жыл бұрын
Well done. Thank You
@prathamva7392
@prathamva7392 8 жыл бұрын
Thanks This was Amazing...Made Rpi Playful and Intresting☺. Happy New Year 2017
@ddmdavid1
@ddmdavid1 9 жыл бұрын
When I put the led like in the scheme it doesn't give any light and when I remove the resistor it gives a little bit of light. Why does this happens?
@VishalChoudhari11
@VishalChoudhari11 7 жыл бұрын
The resistance value of your resistor may probably be too high. Do read the value of the resistance from the colour coding on the resistor before using it. Make sure the resistance you use, matches with the specs of your LED. Also, don't use a too low resistance. The pin may end up drawing more current than the maximum rating, which may result in your Pi getting fried. Cheers!
@kellyrigsby1502
@kellyrigsby1502 5 жыл бұрын
Paul I have a question, I have been following along with your videos, I keep getting an error "TypeError builtin_function_or_method_object is not subscriptable" and this is after I have done an update/upgrade could you please help me out
@jwd.t
@jwd.t 6 жыл бұрын
You sir just got a new sub from me. :D
@hectorsalgado5865
@hectorsalgado5865 7 жыл бұрын
Hi Paul, I was following your excellent tutorial on the GPIO output to control an LED, but when I ran the python code that you typed, I kept getting the following error message: "unsupported operand type(s) for ** or pow( ): "int" and "str". I also used the "^" to multiply by "bright" but the same error message popped out. Now, I'm really learning my way around pi and python language, but I don't know why on my program the "bright" input keeps being "rejected". I'm using Python 3.4.2. Would that make a difference? Thanks Paul! Your videos are very informative!!
@paulmcwhorter
@paulmcwhorter 7 жыл бұрын
All my lessons are on Python 2.7. You should be able to run python 2.7 and it should work on that.
@09btg
@09btg 6 жыл бұрын
how to create a button to make it do two functions for example wen the button is pressed it should stop music and pause a slideshow using feh and when button is release it should play and resume the slideshow
@pavanbhat92
@pavanbhat92 6 жыл бұрын
Is it same for raspberry pi zero w?????????
@MartinThong
@MartinThong 8 жыл бұрын
how should i run it if i use an IDE, eg geany, for my python script?
@Johs4490
@Johs4490 5 жыл бұрын
Hi Paul great video easy learning I like your stile, Hooked my Pi up to a relay board with 2 relays , my python code needs false to turn the relay on and True to turn off. Can you explain this please. :-)
@deamontana596
@deamontana596 7 жыл бұрын
Is there a way to give Pi GPIO privileges so that I do not have to type "sudo" when using the GPIO pins? Also, is there a way to change Pi's name without just making a new user?
@ricacha6
@ricacha6 6 жыл бұрын
Haven't received my Pi yet so I can not test it, but I believe Howard2k79 solved it on the comments for lesson 21: Howard2k79 Hi, you forgot some groups the pi user should be in. It's "spi" and "gpio". Does that actually work?
@aynursunagatullin7029
@aynursunagatullin7029 4 жыл бұрын
Amazing!
@ezeprojects5425
@ezeprojects5425 8 жыл бұрын
excellent! appreciate.
@nacanielitabua3143
@nacanielitabua3143 8 жыл бұрын
I want to read the pulses from a motor encoder via the RPi's GPIO.....How would I monitor this pin??...I want to count the pulses from the encoder...using interrupts....I have done it in Arduino......So essentially I want to implement a counter ....I am having trouble understanding the concept of reading the pins and to read it (count it) every time a pulse passes......Like for arduino we have functions like digital read.......
@RSuarez66
@RSuarez66 6 жыл бұрын
How can I make a traffic light controller (4 semaphores, (4 red, 4 yel, 4 grn), like in a regular corner) with RPi 3? I can make the circuit, but I would like to program it in C. I am still a beginner in programming in C. How can I command the GPIO's in C? Are there any limits as far as how much current the GPIO's can drive?
@gopinathmurugan3710
@gopinathmurugan3710 4 жыл бұрын
Is there any other way to access GPIO pins without using sudo command?
@adamjensen6376
@adamjensen6376 7 жыл бұрын
hey Paul Got a min i got a question here about GPIO and network
@KJ7JHN
@KJ7JHN 7 ай бұрын
rpi.gpio no workie on Windows. Is there a raspberry pi emulator you'd recommend?
@hassinayaz7310
@hassinayaz7310 9 жыл бұрын
It was great :D
@mattbertsch2860
@mattbertsch2860 3 жыл бұрын
I love your lesson I have a problem tho I think there getting out of date I have a raspberry pi 4 and I can't get the pins to work
@yuchaosys
@yuchaosys 7 жыл бұрын
lot of thanks to u
@bishalgautam8177
@bishalgautam8177 7 жыл бұрын
Hello sir,i am currently learning for my major project. I want to control the raspberry pi GPIO pins from the html page without using wiringpi library . Using RPI.GPIO has been so much difficult for me can you please help me . I would appreciate your help.Thank you in advance.
@CassyMorlock
@CassyMorlock 8 жыл бұрын
Next time You forget to use sudo, try using "sudo !!" or "sudo bang bang" it comes already installed in most linux systems; it will run the last command as sudo.
@farhanchowdhury6935
@farhanchowdhury6935 4 жыл бұрын
After i write GPIO.setmode(GPIO.BOARD) shows error bash: syntax error near unexpected token 'GPIO.BOARD' shows What should i do?
@ernierader9314
@ernierader9314 3 жыл бұрын
Has anyone encountered an "IndentationError: unexpected indent" error after the for loop statement in this program where the light is turned on and off? Using a Pi 400
@ardnano3223
@ardnano3223 7 жыл бұрын
Thanks
@haowang9515
@haowang9515 7 жыл бұрын
what should i do when the pin doesnt work...
@ShastaDoktorG
@ShastaDoktorG 6 ай бұрын
I needed to identify the blink_num as an integer rather than a string. blink_num=int(input("How many..."))
@ramink1990
@ramink1990 6 жыл бұрын
LED stays high even , I type the cleanup code but it doesn's work
@fr0iler578
@fr0iler578 8 жыл бұрын
Is it python 2 or 3
@paulmcwhorter
@paulmcwhorter 8 жыл бұрын
My stuff is done on python 2 so things might be a little different on python 3
@karthikbiju3367
@karthikbiju3367 8 жыл бұрын
Why we are importing RPi.GPIO as GPIO?
@MinecraftZockaa
@MinecraftZockaa 6 жыл бұрын
To save the number of needed keystrokes
@surajpawarmamidi704
@surajpawarmamidi704 7 жыл бұрын
The circuit shown in the toptechboy.com was not correct sir... Please make it correct sir. Thank you :)
@PhantomKThief
@PhantomKThief 8 жыл бұрын
Yeah!
@rudyakoya4148
@rudyakoya4148 8 жыл бұрын
Sounds linke. a selfi?
@khaledmohsen6087
@khaledmohsen6087 5 жыл бұрын
👍
@Althu-blog
@Althu-blog 6 жыл бұрын
wery naise your speeshe ant video adting wery naise am wery happy sooper amsteding this video am wery happy to waching this video
@mohamedkhaled-qc7kb
@mohamedkhaled-qc7kb 6 жыл бұрын
Thank you for teaching but I want to book or documentation or source to learn all about coding in raspberry
@77936fief
@77936fief 5 жыл бұрын
next time you ran a command without sudo and you should have, just execute sudo !!, it will run the previous command as sudo
@okeania6529
@okeania6529 7 жыл бұрын
do yuo close tabs?
@paulmcwhorter
@paulmcwhorter 7 жыл бұрын
Tabs are closable?
@okeania6529
@okeania6529 7 жыл бұрын
yes clin in te x on the tabs!
@e4ent23
@e4ent23 2 жыл бұрын
25
@e4ent23
@e4ent23 2 жыл бұрын
17
Raspberry Pi Linux LESSON 27: PWM Output on GPIO Pins from Python
39:36
Raspberry Pi Linux LESSON 24: Running Python on the Raspberry Pi
14:33
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Raspberry Pi LESSON 30: Control LEDs with Buttons on GPIO Pins
20:31
Paul McWhorter
Рет қаралды 57 М.
Raspberry Pi LESSON 31: Creating a Dimable LED Using Python
21:36
Paul McWhorter
Рет қаралды 25 М.
Raspberry Pi Robotics #1: GPIO Control
15:38
ExplainingComputers
Рет қаралды 849 М.
Raspberry Pi: Using GPIO Inputs
18:41
ExplainingComputers
Рет қаралды 585 М.
Raspberry Pi LESSON 32: Analog Input for the Raspberry Pi
9:57
Paul McWhorter
Рет қаралды 68 М.
Raspberry Pi Linux LESSON 5: Naming Files and Folders
10:21
Paul McWhorter
Рет қаралды 37 М.
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН