Raspberry Pi Linux LESSON 27: PWM Output on GPIO Pins from Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

ความคิดเห็น • 132

  • @thronabulax
    @thronabulax 3 ปีที่แล้ว +1

    I learned more from your honest sense of humility than from the lesson content. You were not afraid to show your human fallacy. In the face of failure you did not become frustrated, you did not edit out the mistakes, but showed us the unvarnished approach to problem solving, “warts and all.” Found the problems and not only fixed them, but improved on them. The spirit of a true engineer. Bravo! It also shows that even folks who have ADHD, or difficulty spelling can be extremely intelligent and deserve our compassion, patience and admiration.

  • @nigelworwood8530
    @nigelworwood8530 5 ปีที่แล้ว +14

    I like the fact that you let us see you finding the problem. So often in other tutorials there is an edit and we do not learn the process. Okay the "sart" example - Remember the times it has happened to us. We tend to read what we think it is supposed to be. Does that make sense?

  • @alanproctor8324
    @alanproctor8324 9 ปีที่แล้ว +8

    Just starting out with python and a raspberry pi and this is by far most helpful video I have watched yet, all the other, thankyou

  • @masdi-2173
    @masdi-2173 7 ปีที่แล้ว +5

    An almost 3 years old video, and still a great tutorial video.. Thanks sir! Awesome!

  • @ezeprojects5425
    @ezeprojects5425 8 ปีที่แล้ว +1

    I have appreciated your videos so much, wish I had come across them in the beginning of my Pi adventure. I was a programmer for decades, was not an engineer like you, so have learned a thing or two about debugging outputs. The Python processor is telling you exactly which line the error is on, line 6. Sometimes, an error will be caused by a previous error, but this script is so small, the place to start and end is line 6. I, too, have stared at misspellings and not seen them, just keep looking. Sometimes I call a friend for a "second pair of eyes". Plz keep up the great work. Your students do not know just how lucky they are.

  • @jensemilhansen1602
    @jensemilhansen1602 8 ปีที่แล้ว +5

    It turned on with 0 as input because 2^0 is 1 as you can see in the video too 35:55

  • @mintoo2cool
    @mintoo2cool 4 ปีที่แล้ว

    thanks for these tutorials. there are helpful refreshers for guys like me who worked with 16bit microcontrollers in their college and never touched them again ...
    tip - you don't need to keep python as a superuser. you can add user 'pi' into the sudoer list (not recommended) or you create another user (like gpio) and add that user to the sudoer list and everytime you want to run programs that interact with gpio, you sudo su - '' to switch to that user and run your python programs without having to sudo each time.

  • @norfazrinadzri4982
    @norfazrinadzri4982 9 ปีที่แล้ว

    The Best tutorial for Pi. Never seen others make a tutorial clear like u sir.

  • @jasoncherry5849
    @jasoncherry5849 8 ปีที่แล้ว

    Your videos have helped me create and develop my capstone project for college. Thank you for the time and effort you have put into your tutorials.

  • @adamwalter2573
    @adamwalter2573 3 ปีที่แล้ว

    Anything that works in background ? I mean keep values set in some sort on a buffer, so that once application exists, the state is still the same ?

  • @jokano6865
    @jokano6865 5 ปีที่แล้ว +1

    The reason the "bright" variable at 32:30 didn't work as intended is because when you prompt the user with an input() fuction, python stores the input as a String data type. Because of this, you need to change the data type of "bright" from string to integer. The solution should look something like 2^(int(bright))

  • @alekrand85
    @alekrand85 4 ปีที่แล้ว

    Im trying to use my pi to drive a set of mosfets for a HV flyback. In a half bridge configuration. Very similar to a zvs drive. Do u have any tips on how to go about this?

  • @swwewearwffv5099
    @swwewearwffv5099 8 ปีที่แล้ว +1

    pulse width modulation right? not pulse width modification....

  • @NelsonGallo1
    @NelsonGallo1 7 ปีที่แล้ว

    Is there another way to stop the program without the keyboard interruption? For example with another application py. That is, I want an application for me to illuminate the led in 50% and another to turn it off.

  • @seanli75
    @seanli75 4 ปีที่แล้ว

    36:36 i am having trouble with the **(power of ) it keeps showing blank on my LED and yes i did hook things up right

    • @seanli75
      @seanli75 4 ปีที่แล้ว

      can anyone help me?

    • @seanli75
      @seanli75 4 ปีที่แล้ว

      okay so the problem is that when i input a number like 4 it doesn't even light up

  • @TheSuperSangan
    @TheSuperSangan 8 ปีที่แล้ว

    is there a way to do a case in python?
    like have the leds light on when 1 or 2 are pressed then off when 3 or 4 are pressed?

  • @darthenx2585
    @darthenx2585 6 ปีที่แล้ว

    Question... if I am wanting to check if the pwm.start() has been initiated , how can I use that in an If statement?

  • @robbery30
    @robbery30 3 ปีที่แล้ว

    What's the raspberry pi equivalent for Serial.begin(9600)?

  • @icarus7471
    @icarus7471 7 ปีที่แล้ว

    Man I am just a 14 year old but I was able to understand each and everything . Your each and ever lesson was helpful . You are doing a great job with these lessons !!! These are , by far ,THE BEST TUTORIAL FOR UNDERSTANDING THE RASPBERRY PI !!!!!!!!!!!

    • @paulmcwhorter
      @paulmcwhorter  7 ปีที่แล้ว +1

      Thank you for the kind words, and please share the videos with others. We need more people who know this stuff!

    • @icarus7471
      @icarus7471 7 ปีที่แล้ว

      For sure!!

  • @bmoviestgams
    @bmoviestgams 9 ปีที่แล้ว

    Hello ! Can i use the raspberry in order to control 4 brushless motors at the same time ?(with python) or i will need a ServoHAT to do that ?

  • @yugeshkc9026
    @yugeshkc9026 4 ปีที่แล้ว

    How can we use PWM if the LED is powered by an external battery?
    I would be thankful for your response

  • @Analyse_US
    @Analyse_US 7 ปีที่แล้ว

    Thanks for not editing out the sart error. As a beginner coder, it's reassuring to see others make this type of simple coding errors..

  • @averycox1429
    @averycox1429 5 ปีที่แล้ว

    Can you use a pie to control devices that are using devicenet?

  • @prashantmeti7986
    @prashantmeti7986 3 ปีที่แล้ว

    Can we control 24 v LED brightness sir

  • @JohnWest4
    @JohnWest4 2 ปีที่แล้ว

    4 Years hence and it's still great!

  • @samsont81
    @samsont81 9 ปีที่แล้ว

    can i control a brushless motor using this connected to Esc ?

  • @sawansaurabh6457
    @sawansaurabh6457 7 ปีที่แล้ว

    hi paul, great video. I wanted to ask that in the final code, every time when you set the brightness, the code loops back and asks the user for another entry. So, how does it reach to the GPIO.cleanup() part cuz evrytime it'll just loop back asking for input.. ?

  • @debabrata2137
    @debabrata2137 7 ปีที่แล้ว

    sir I have raspberry pi 3 B. i want to control a servo by taking the sensor data from a mobile. can you please help me?

  • @DodgyBrothersEngineering
    @DodgyBrothersEngineering 7 ปีที่แล้ว

    First video of your I've watched and I going to go right ahead and give myself a pat on the back as I spotted all of the mistakes you made as you typed them. Considering I have never written a line of python in my life I thought I did pretty well understanding it.
    Thanks for making it so easy to follow, and sometimes it is good to include the bloopers because it helps with understanding how to diagnose the errors that happen in real life.
    Also I do know if there is a way to exit the program in a graceful manner since they is no exit out of the loop that I could see.

  • @jalilabdul8986
    @jalilabdul8986 7 ปีที่แล้ว

    Can we make an "inverting pwm output" on raspberrypi?

  • @mohamadilham1384
    @mohamadilham1384 6 ปีที่แล้ว

    Can i use multipe pin for another PWM?

  • @samarthmoudgalya8747
    @samarthmoudgalya8747 7 ปีที่แล้ว

    I have a list of int say [1,0,1,0] . How do i send this data to the cro. pls help

  • @harleycruiser4331
    @harleycruiser4331 4 ปีที่แล้ว

    I really enjoy your videos especially your diagnosis of a problem, and yes I like the BOOMs, I do that myself when it works.

  • @flaviogjoni5747
    @flaviogjoni5747 3 ปีที่แล้ว +1

    34:14 that smile made me happy too c:

  • @mohammedal-alaw6249
    @mohammedal-alaw6249 6 ปีที่แล้ว

    Using the Oscilloscope; What is the max. P.W.M. possible

  • @sst8872
    @sst8872 4 ปีที่แล้ว

    Happy New Year Paul! I'm surprised to find myself watching your loooong~ video nonstop. You are truly marvelous, Grand Pa Paul. Take care of your health. Again Thank you!

  • @MartinThong
    @MartinThong 8 ปีที่แล้ว

    So what is the point of changing the frequency if it does not affect anything?

    • @joshdcunha8674
      @joshdcunha8674 8 ปีที่แล้ว

      I think that for the LED the only thing that matters is the voltage it's receiving (which is controlled by changing the duty cycle). If you try changing the frequency with a Piezo element you get different sounds.

  • @yunusemrecagatay2146
    @yunusemrecagatay2146 5 ปีที่แล้ว

    How can i read pwm signal on raspberry
    Please help me

  • @jimmykan7873
    @jimmykan7873 7 ปีที่แล้ว

    Can use this to control the speed with l289n motor driver?

    • @arpit11rastogi
      @arpit11rastogi 7 ปีที่แล้ว

      i m yet to try that

    • @k1ng401
      @k1ng401 5 ปีที่แล้ว

      I know this is a late reply but yes you can. Just done it myself.

  • @stevec3h8
    @stevec3h8 7 ปีที่แล้ว

    Paul, thanks for a great series! I appreciate your teaching style. I have a question related to the GPIO.cleanup() statement. I've noticed a couple of times when you've stopped a program in the middle and it doesn't get to execute the cleanup statement, the next time you run the program it gives a warning message. This is just a question because I'm new to Python and Pi, would it be a good practice to start your program with a GPIO.cleanup() statement so that every time you execute your program, you know you are starting with a clean slate? Again ... thanks for a great series and all the time you have put into this effort!

  • @abhishektyagi7513
    @abhishektyagi7513 3 ปีที่แล้ว

    You can use the 'try and except' statements in python. That way, you can be sure that the cleanup happens even if there's a bug in the main code.

  • @airbrushernst
    @airbrushernst 9 ปีที่แล้ว +1

    Tnx for explaining!
    Isn't ((2**bright)-1) better? with input 1-7?

    • @Jockeponkenboy
      @Jockeponkenboy 6 ปีที่แล้ว

      Why not just (bright * 10) and limit to 0-100.. and have the possibility between 1-10

  • @charlesbrewer6552
    @charlesbrewer6552 7 ปีที่แล้ว +1

    Hi Paul
    I really Appreciate your videos.
    Absolutlely great.
    I was thinking it might be good practice to puit a "clean-up" statement a the beginning of all my programs?

  • @ruchitpanchal2074
    @ruchitpanchal2074 7 ปีที่แล้ว

    That Oscilloscope line can be made horizontal by turning a screw. It should be somewhere near the screen. The old Cathode Ray Oscilloscopes have the screw I'm not sure if the new Digital ones have a similar calibration feature. Enjoyed the Video and I'm learning a lot :) Thank You :):)

  • @marcvanelverdinghe50
    @marcvanelverdinghe50 4 ปีที่แล้ว

    Even after all these years interesting enough to base a tobot project on!

  • @timb1648
    @timb1648 9 ปีที่แล้ว +28

    Great video... I was yelling at the screen with sart.

    • @alkhashtee
      @alkhashtee 5 ปีที่แล้ว

      Ahahahah me too

    • @salioudiallo582
      @salioudiallo582 5 ปีที่แล้ว

      @@alkhashtee HAHAHA me 3

    • @toasterbath1395
      @toasterbath1395 4 ปีที่แล้ว

      Saliou Diallo hahahaha me *4* *😂*

    • @seanli75
      @seanli75 4 ปีที่แล้ว

      @@toasterbath1395 me five

    • @seanli75
      @seanli75 4 ปีที่แล้ว

      @@toasterbath1395 *hahaha me 5

  • @seanli75
    @seanli75 4 ปีที่แล้ว

    33 33:30 you could just put GPIO.setwarnings(False) and it will not give you the error

  • @mathiassimson4167
    @mathiassimson4167 4 ปีที่แล้ว

    You can write # pinout in terminal and see GPIO and other information about your Raspberry PI.

  • @quantummandavid
    @quantummandavid 7 ปีที่แล้ว

    PWM = Pulse Width Modulation Thanks for posting

  • @MarkBamford
    @MarkBamford 3 ปีที่แล้ว

    Absolutely brilliant tutorial Paul. Thanks so much. Regards, Mark

  • @nicole4422
    @nicole4422 7 ปีที่แล้ว

    pow(int base, int exp) also works

  • @squeakycheex7771
    @squeakycheex7771 ปีที่แล้ว

    Thanks!

    • @paulmcwhorter
      @paulmcwhorter  ปีที่แล้ว

      Thanks! REally appreciate that.

  • @dwaynemartin9944
    @dwaynemartin9944 5 ปีที่แล้ว

    Loved the video, love all your videos. This has helped me with my Pi foo a lot, and I really appreciarte your efforts.

  • @farhinismail3978
    @farhinismail3978 7 ปีที่แล้ว

    mr paul how about making a tutorial on making a database that i can take and send information. i really look forward to it because i enjoyed your lessons

  • @aleksandrjaworski7789
    @aleksandrjaworski7789 8 ปีที่แล้ว

    Thank you for your tutorials! I had my first experiments with arduino thanks to your videos.

  • @aynursunagatullin7029
    @aynursunagatullin7029 4 ปีที่แล้ว

    Thank you Mr. McWhorter, very good!

  • @ReCoN12371
    @ReCoN12371 8 ปีที่แล้ว

    Great tutorials!!! I"m learning so much and you make the learning easy and fun.

  • @ki-wonlee4
    @ki-wonlee4 6 ปีที่แล้ว

    Thank you for your contribution in raspberry pi dummy world. I like your class. Also I love your BOOM!

  • @Popart-xh2fd
    @Popart-xh2fd 8 ปีที่แล้ว +6

    One day Python will come with a Spell Checker...

  • @PirithiumX
    @PirithiumX 8 ปีที่แล้ว

    Thank you very much for this contribution. I will be looking forward to more in the future. Great work.

  • @elhamkeshavarzarshadi
    @elhamkeshavarzarshadi 5 ปีที่แล้ว

    you can use HIGH instead of 1 or TRUE and HIGH instead of 0 or LOW

  • @smackledorfmcsween
    @smackledorfmcsween 7 ปีที่แล้ว

    You can tell this guy was tired. when he made this. I'm subscribed due to the fact that he reminds me of my tael teacher Mr. Blair.

  • @sampro454
    @sampro454 7 ปีที่แล้ว +1

    36:07 When python doesn't let you get carried away.

  • @soundguydon
    @soundguydon 8 ปีที่แล้ว

    PWM = Pulse Width Modulation. Also, I really like your vids, but just as a heads up, when you're using NANO, you can just hit ^X when you're done editing, and it'll ask you if you want to save it. You don't have to do ^O then ^X :)

  • @erygion
    @erygion 5 ปีที่แล้ว

    Great lesson Mr. Mcwhorter, I learned a lot. What ever happened to doing our comments in the code like good boys and girls? (I know it would take longer...)

  • @rodrigo7089
    @rodrigo7089 5 ปีที่แล้ว

    Thank you very much Paul!. Great tutorial as always

  • @Popart-xh2fd
    @Popart-xh2fd 8 ปีที่แล้ว

    Sart(re) is a philosopher and 2^7 is 128! :)

  • @julianray6802
    @julianray6802 5 ปีที่แล้ว

    Boom! These videos are such good fun for a newbie like me! Thank you Paul, and I like the booms(!) ;)

  • @jokano6865
    @jokano6865 5 ปีที่แล้ว

    absolutely amazing video, extremely clear. Thank you!!

  • @seanli75
    @seanli75 4 ปีที่แล้ว +1

    STOP with the DISLIKES AND LIKE IT!!!!!!!

  • @daesoolee1083
    @daesoolee1083 6 ปีที่แล้ว

    Paul McWhorter is my incredible teacher hhh I love his teaching videos

    • @paulmcwhorter
      @paulmcwhorter  6 ปีที่แล้ว

      Thank you for the kind words!

  • @loulounet777
    @loulounet777 8 ปีที่แล้ว

    You do know that all analog oscilloscopes have a trace rotation potentiometer...

  • @MohamadNaseer
    @MohamadNaseer 8 ปีที่แล้ว

    good work sir....

  • @maffysdad
    @maffysdad 9 ปีที่แล้ว

    Thank you, this has been a interesting video, somewhat more informative than some other tutorial videos in that it was all 'on the fly', and the image has the three images in one, the presenter, the pi, and the programming, makes it much more instructional, and yes, I was shouting at the screen, haha! But that's how we all learn isn't it eh? :-D

  • @AlanHeigl
    @AlanHeigl 4 ปีที่แล้ว

    great lesson

  • @pin4586
    @pin4586 8 ปีที่แล้ว

    Amazing tutorial !

  • @steve905
    @steve905 5 ปีที่แล้ว

    Lesson is: Always read the error message carefully.

  • @kevintamez
    @kevintamez 9 ปีที่แล้ว +5

    realy nice tuts, realy useful:)

  • @Bigboss-zn8pv
    @Bigboss-zn8pv 6 ปีที่แล้ว

    Thank you so much, great video

  • @cren189
    @cren189 7 ปีที่แล้ว

    if only my school wifi would not stop the video after one second

  • @LetMeThinkItThrough
    @LetMeThinkItThrough 5 ปีที่แล้ว

    ^ is the sign for XOR thats is why it turned off, 2^2=0, hahah. It was amusing too watch the small "misses"

  • @mgtowluau5651
    @mgtowluau5651 9 ปีที่แล้ว

    ah ha
    dutycycycycycle = round((1-e^-bright)*100)
    bright is 0 to inf
    in practice bright = -ln(0.005) = 5.299 should yield 100 but higher values are safe for entry.
    The point of this being the use of e for math nerds and a scale from 0 to inf.

  • @AranyaSen
    @AranyaSen 9 ปีที่แล้ว +4

    Excellent video! Too many "boom"s for my liking though :P

  • @yuchaosys
    @yuchaosys 7 ปีที่แล้ว

    great stuff!

  • @rasheedataliep5757
    @rasheedataliep5757 3 ปีที่แล้ว

    thank you so much

  • @gavares3
    @gavares3 6 ปีที่แล้ว

    oh this guy is awesome. love your videos. please keep them coming through. my confidence went through the roof with this guys explanations.

  • @franknarc
    @franknarc 7 ปีที่แล้ว

    You have a Hummer, Mercedes, Jaguar, Nissan 350Z...But still, you want somebody to donate an Oscilloscope ?? BOOOOM !!!

    • @paulmcwhorter
      @paulmcwhorter  7 ปีที่แล้ว +1

      I said cars I have "HAD" not "HAVE". When I was working as an electrical engineer I made lots of money. Then I retired and I teach school, so now I drive a little toyota pickup. So, I dont have cars like that any more.

    • @franknarc
      @franknarc 7 ปีที่แล้ว

      But still it makes no difference, coz it wasn't only Hummer or only Mercedes or only Jaguar...you've had ALL THREE !!! BOOM !!!
      Hope you can make another series of videos "How to make lots of money (Electrical Engineers Edition)" and soon, it'll also be a HIT !! BOOOOOOOOM !!! :P

    • @paulmcwhorter
      @paulmcwhorter  7 ปีที่แล้ว +3

      Actually being an electrical engineer is probably the most likely way for most people to become wealthy. Sports, rap, music, lottery . . . those are all dreams. But if you work hard, get an engineering degree and then work hard at your job, you can put do very well. That is one of the reasons I teach . . . I want the kids to see that there is a path that is real for them if they are willing to work.

    • @franknarc
      @franknarc 7 ปีที่แล้ว

      Nah, if you are really ready to work hard, sports, rap, music,..anything can be lucrative...
      Wouldn't you agree that Eminem knows better vocabularies than Shakespeare ?? B)...
      But anyway...you re doing a great job !!
      Make some BOOOM !!!
      Only then it makes you PAUL MCWHORTER B)
      Else it sounds like somebody else :P

  • @stefanooliveira
    @stefanooliveira 3 ปีที่แล้ว

    Perfect!!!!

  • @RinksRides
    @RinksRides 7 ปีที่แล้ว

    you could just as easily do su pi instead and be locked as super user... Subb'd & liked!
    don't you have an astig/rotate/brightness level adjustments on that o-scope?

  • @calpardo
    @calpardo 4 ปีที่แล้ว

    LIKED IT

  • @oleynikdenis
    @oleynikdenis 9 ปีที่แล้ว +8

    Boom )

    • @fanyinU
      @fanyinU 6 ปีที่แล้ว +1

      when go over 128 haha

  • @ku567318
    @ku567318 8 ปีที่แล้ว

    Paul,
    Love the videos. If I could offer one suggestion... Please use the term guys and "GIRLS." I'm trying to discover my my little girl's interest by watching your videos with her.
    Thanks.
    Ken

    • @paulmcwhorter
      @paulmcwhorter  8 ปีที่แล้ว +1

      for me, "Guys" is synonymous with "people" or "folks". It is intended to be gender neutral. Just like our team is the "Space Cowboys", but a key leader is a girl.

    • @ku567318
      @ku567318 8 ปีที่แล้ว

      Thanks Paul. My girl will love your comment.

  • @seanli75
    @seanli75 4 ปีที่แล้ว +1

    can you stop saying BOOM?

  • @cannabis7619
    @cannabis7619 6 ปีที่แล้ว

    i grabbed my monitor and yell at it STAAAAAAAAAAAAAAART !!!!!!!! after that i stopped watching youtube sarted my pi.

  • @dmkays
    @dmkays 5 ปีที่แล้ว

    Cool Beans d;^}

  • @dvsmotions
    @dvsmotions 8 ปีที่แล้ว

    hahahaha