6 years later and this is still a great tutorial. Thank you Paul
@paulmcwhorter3 жыл бұрын
Glad it was helpful!
@Lecon608 жыл бұрын
Today I decided that I would get into Raspberry Pi and I thought i'd do a search and came upon this lesson. I used to have fun with turbo languages and was pretty upset when MSDOS went away. I haven't done any code since 99. This may be the beginning of a new hobby for me. Thank you.
@albireo98 жыл бұрын
Paul: Thank you for the great video! Guys: I added Python code to display DutyCycle values onscreen and to make a clean departure on Ctrl-X. The code below is calibrated for my particular servo. # Python code for Raspberry Pi: Rotate servo horn from 0 to 180 degrees; 180 to 0 degrees forever (Ctrl-X to stop) import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) # That is BCM pin number servoPin=18 GPIO.setup(servoPin,GPIO.OUT) pwm=GPIO.PWM(servoPin,50) # BCM pin 18 at 50Hz frequency pwm.start(2) # DutyCycle 2 is "full-left" position (0 degrees, if you will) on my servo try: while(1): for i in range(0,180): DC=1./18.*(i)+2 pwm.ChangeDutyCycle(DC) print("A:DutyCycle: %s" % DC) # Display DC values onscreen time.sleep(.01) for i in range(180,0,-1): DC=1/18.*i+2 pwm.ChangeDutyCycle(DC) print('\033[1;36mB:DutyCycle: %s\033[1;m' % DC) # Display cyan-colored DC values onscreen time.sleep(.01) except KeyboardInterrupt: # Clean departure on Ctrl-X pwm.stop() # Stop the servo GPIO.cleanup() # Housekeeping :)
@martinlewis6453 жыл бұрын
I'm jumping back and forth between the newer Python tutorials and these. Lots of fun. Thanks again!
@berndklee55618 жыл бұрын
Thank you so so much for your videos! There are so many others, but either they're only 2 minutes long (which is clearly not enough to explain such a complex thing), or they take about an hour, but do not manage to explain it anyway! And this is why I normally don't watch those videos from the beginning to the end, but YOUR Videos are simply worth the time! I owe you a lot, thank you 👍 Greetings from Germany! 👋
@johncgibson47208 жыл бұрын
Your PWM library is very good and stable. I have seen other people's programming that the servo arm is always twitching. Your servo control is very precise and no twitching at all.
@resrussia6 жыл бұрын
Thanks for an excellent video on controlling servo motors. As a result of your video, my comfort working with the RPi and servo motors has increased tremendously. Keep up the good work.
@mikehauk60797 жыл бұрын
I will admit... frustration doesnt come close to how I was feeling... I sat back and told myself, "your overthinking everything. Let the pi do the work..." WORKS like a charm!
@MartinJohnstone4 жыл бұрын
Awesome clarification of PWM! Man, I've been looking for a lesson like this! Very clear and concise, I checked out lesson 27 - great clarification! Thank you!
@Ty2rad4 жыл бұрын
thank you for these tutorials. still incredibly helpful and relevant 4+ years later
@rajcodes1005 жыл бұрын
Thanks Sir Paul - you have surely add to my insight how to control electronics using software - really appreciated.Your pace allows beginners to understand better and you explain stuff nicely.Thanks so much again - I have a pi but I guess i need to get a servo and a external power supply to try this out.
@nimfbdhdkdm3 жыл бұрын
FINALLY A DECENT TUTORIAL ON THIS
@adamc27873 жыл бұрын
This lesson helps me understand how to start coding small things its awesome. You knowledge helps a lot . Big Up
@paulmcwhorter3 жыл бұрын
Glad to hear that!
@michaelnoardo33154 жыл бұрын
you are my hero, the most inteligent maker in youtube
@anarchylabs99975 жыл бұрын
Just to keep a good video going. the 9g servo stats are: full left = 2. mid = 7. full right =12
@jatinmayekar37798 жыл бұрын
Thanks a lot sir!!Wish we had teachers like you
@jingyiwu77467 жыл бұрын
Superior!!! All the control that you can imagine for control a servo!!!!
@prathamva73928 жыл бұрын
Thank you for the Amazing tutorial.I wish i had Mathematics Professor like you.The Math logic you used in the program made me to Realize the importance of" Lines and Angles" :)
@Fiskers224 жыл бұрын
When you calculate "DC" and multiply 1./18. to make it (float) the variable must also be a float, input must be a float also. float(input("text") this is so you multiply Float times Float. See what I mean... Saw this error while running "Thonny Pi IDE" Loved the lesson. John
@LAStupidDrivers8 жыл бұрын
How to do with continuous servo motor?
@aynursunagatullin70294 жыл бұрын
I really liked your explanation especially the formulae, theory and code
@shampavmancg6 жыл бұрын
This was very informative. Thanks. I've started a project to build my own gimbal for which the PWM explanation and this video will be very helpful.. Thanks
@sskey898 жыл бұрын
Is there a way to have the servo report its position back to you? Or would that depend on the type of servo?
@minhtruong94082 жыл бұрын
Thank you Paul you are the BEST!
@rob26r4 жыл бұрын
Great video - any viewing/reading suggestions on how to move the servo motor based on a tensorflow lite object detection results on a Pi. For example, move it 30 degrees if object detection is apple and move it 160 degrees if banana? Thanks!
@auke12604 жыл бұрын
Thank you very much! Would some similar be possible with a large motor aswell?
@erygion5 жыл бұрын
Wonderful lesson Mr. Mcwhorter, (I love the long ones) all the possibilities with the other lessons makes quite the tool set. Thank you sir. ❤🍇🥧
@mirak14707 жыл бұрын
very ,,,,VERY good..... the real lesson....is like a school .... THANKS
@fernandowosniak87828 жыл бұрын
great video and explanations but, I noticed on the previous video that the pwn generated by the pi is not that stable. I tried this same code on my servo (futaba s3003) and I am having problems with "vibrations". How is it possible? Like, how do you keep your motor on the right position with an unstable pwm? Thanks for the help.
@TheNewfiePilot5 жыл бұрын
Paul, I am writing a simple script to move a servo from 0-90 degrees and was wondering if there is a way to slow down the speed of the servo?
@ADJai7 жыл бұрын
very nice and understandable lecture, I love all your PI projects. Thanks Mr. Paul.
@Chretze4 жыл бұрын
Can you turn any servo 180 degrees like that? With my normal RC radios I can get my standard servos to turn about 90 degrees total. Is that because these standard radios only send a limited range of PWM signals? Or are you using a special servo that turns further? Thanks in advance!
@LucaPR06 жыл бұрын
what is the maximum torque this thing can output? i would like to use it to flip a switch on a power strip
@muhammadalam24985 жыл бұрын
This is great! Many thanks from Pakistan!
@manishasonar17333 жыл бұрын
Thank u i am stucked at this point but you solved it. Thank u
@schwarz5008 жыл бұрын
you're awesome i didn't understood it but now i understood. Good Job! Keep it up. Thank you
@1412dante8 жыл бұрын
great instructor atuk! thanks!
@SanjivVenkatram5 жыл бұрын
Greetings and thanks much for sharing Paul. Very clear, easy to follow and here's wishing you and family a very happy new year! Here's to making it a great one! Kind regards.
@Cobacanal9 жыл бұрын
Thanks From Chile you are a great Teacher ! Greetings
@SonnyLando5 жыл бұрын
any ideas on controlling a continuous servo with a feedback wire?
@adulthumor82034 жыл бұрын
my servo needs more power. I am connecting an external power souce to power the servo but it's going haywire. I would like to know how would you connect a common ground.
@turboromy7 жыл бұрын
Works with zero problem. Ah, but servo motor is getting pretty hot. Great video.
@turboromy7 жыл бұрын
Problem was solved when I change the power supply from supplied to one of those power bank which supplies 2.1A at 1.5v
@CryhavocMike8 жыл бұрын
How would you add a potentiometer to control the duty cycle?
@alokmishra24588 жыл бұрын
which software u r using to record your screen and face is it free
@WCollinsWhiteIII2 жыл бұрын
This is the best! Many thanks. I'm now attending your Pi U. I was looking for the code for this is it available? (Looked online and on your site)
@Sneaky1ne4 жыл бұрын
Great explanation man, good job
@WarpDriveM8 жыл бұрын
you`re the best! good work and thx for your lessons!
@Mobi25257 жыл бұрын
Very good video. I will have to watch the entire series. Could you tell me the purpose of a PWM driver? I recently purchased a PI robot kit and it has a 16 channel 12-bit PWM driver.
@dbhanderi18 жыл бұрын
i have a parallax hb 25 motor controller which says it is to be coded as a continuous rotation servo but i am having difficulties trying to get it to work with my pi
@CatGuyTX9 жыл бұрын
It would be great if you uploaded the servo document to a shared public folder and gave a link for downloading.
@ApplySkills6 жыл бұрын
everything works fine in python interpreter but once I put it a script nothing works. I even used sudo python servo.py.
@AwakenedOne-qu7 жыл бұрын
U R a great teacher!
@javierdarlington48586 жыл бұрын
Hi from Spain. Do you have any lesson about controlling servo with DMA?
@Qornv6 жыл бұрын
great thorough explanations
@JooshyBaby7 жыл бұрын
Thank you so much for this! Seriously saved my skin!
@nathanielbajo1303 жыл бұрын
Is there a way I can get the rust code for this please?
@varkeygeorge32099 жыл бұрын
Great tutorial . Is i possible to conrol multiple servos using GPIO ?
@paulmcwhorter9 жыл бұрын
Varkey George You should be able to control multiple servos by using different GPIO pins. Just remember that servos require lots of current so I would not try and power them from the Pi . . . just control them from the Pi.
@cryptok1d7263 жыл бұрын
Thank you for sharing your knowledge!! great lessens
@paulmcwhorter3 жыл бұрын
Glad it was helpful!
@christiangorman60586 жыл бұрын
Any direction helping with using C++ as a language to program?
@saider8958 жыл бұрын
Great tutorial, but i don't understand one thing, i was under the impression that PWM controls the power strength as demonstrated in previous lesson with the LED, how is it able to actually control which position to go to in here? thanks
@paulmcwhorter8 жыл бұрын
+Haider A PWM means Pulse Width Modulation, and it controls the duty cycle of a pulse train. In effect, half power is full voltage on for half time. Full power is full voltage on for the full time cycle.
@spiderschwein34434 жыл бұрын
your tutorials are awesome thank you very much for helping me out (:
@Ruya_Meltem4 жыл бұрын
Thank you! I have a question. I want the same thing (servo go down and up). It goes down but it does not go up. For the down: duty = 2 while duty = 2: p.ChangeDutyCycle(duty) time.sleep(1) duty = duty - 1 Could you look at this, please? Where is the problem?
@ExcellentEngineering19666 жыл бұрын
This is so helpful for learning python
@ramanandkumar90526 жыл бұрын
why am i not able to move my servo motor connected to raspberry to rotate at different angle in spite of correct code as directed by you and i have also installed servoblaster please give me solution what to do??
@윤준영-g3g2 жыл бұрын
This great video helped me a lot. Thank you very much!!
@paulmcwhorter2 жыл бұрын
Glad it helped!
@sreelekha47272 жыл бұрын
May I know the software used here?
@shawnerz987 жыл бұрын
Thanks for posting this video. It explained a lot. I do most of my stuff with Pi Zero's. So, from gpiozero I was able to import PWMOutputDevice and use (and understand what I was doing) to control a servo. Thanks!
@asimkhan25578 жыл бұрын
Thank you Sir its really very helpfull keep it up...... Love From Pakistan
@dexnaranjo30378 жыл бұрын
Great tutorials, Mr. McWhorter. Thanks for sharing your knowledge!
@govindabaweja35496 жыл бұрын
Hello I have a question, I am using similar code for servo motor, but I want to use distance sensor with it. So I wrote a code, for servo motor to move when distance sensor senses some specific distance. But in my code, servo motor is continuously moving and not coming to the rest position. Is there any way you can help me with this please? Is there any way I can share my code with you so that you can look at it, and let me know what is going on. Thank you for your help in advance.
@WirelessDevelopment8 жыл бұрын
Great Instructor! My servo is jerking a little bit when I stop it at any given angle. I'm afraid that the PI isn't putting out a perfect 50MHz. Everything working as it should.
@paulmcwhorter8 жыл бұрын
Make sure you have a good servo, not one of the cheep ones. Then also make sure you power supply is sourcing adequate curring.
@RinksRides7 жыл бұрын
50MHz for a servo cycle?! Also, RPi.GPIO library has noticeable jitter when PWM'ing. Maybe a better PWM library for python on Pi?
@battery_solar_ev7 жыл бұрын
First off im not even close to a programmer but i am a computer and electronic tech. What i need is this raspberry to take an input (3-5 volts) at random from an outside source and respond by making the servo move 90 degrees left or right and when the input stops the servo goes back to 0. Can that be done?
@Tomdavies2k117 жыл бұрын
build a circuit based around a transistor that flicks a "switch" and thus turning on a program that would move the servo
@valentin687068 жыл бұрын
Thanx you explained it verry well, just two question: how do I connect a second servo and give specific instructions to each servo individualy (is that easy or do I really have to buy a Servo Board?) Oh and olso on what site do I find the same servo as yours?
@fertorres3305 жыл бұрын
hi the question is, are you using rasbian?
@foreducationalpurposes7386 Жыл бұрын
Can raspbery 3 model b carry 3 servoo +? Like that big?
@larbigueraiche67216 жыл бұрын
Hi, great and useful lesson. I want to control a steeper motor using raspberry Pi3 but before doing that I want to simulate the schematic of Raspberry+driver motor+Steeper motor. Is that possible? if yes which software is adequate?
@arunbm1237 жыл бұрын
This is awesome ..100 Thumbs to you !!!
@susheelselvamani66647 жыл бұрын
I'm trying to control the servo with Raspberry Pi but my servo is resting in a stable position. I'm seeing some glitch like a random pulse. What would be the reason for this?
@jamesaxiak80846 жыл бұрын
I get that it starts at 0 degrees and goes to 180 and back, but how do i change it to start at 180 and go to 0 degrees and back?
@RSuarez667 жыл бұрын
I am a rookie in programming and I would like to know how to drive servos with RPi using C. How does a code for this look like? Thank you very much. Love your videos!
@kunal_2657 жыл бұрын
why did you put -1 there in the second while loop
@jmdesros7 жыл бұрын
Put your cleanup call both at the beginning of your python script and at the end. If you break your script it will not give you that warning.
@penguin50967 жыл бұрын
I'm trying to control multiple servos at the same time with my Raspberry Pi. Can someone direct me to a proper video/post of how I can do this?
@chevycamaro-rp6tr7 жыл бұрын
Penguin individually or collectively?
@Denverse6 жыл бұрын
use threading
@bmoviestgams8 жыл бұрын
Can i use this way to controll a brushless motor ? (esc) Thanks btw !
@paulmcwhorter8 жыл бұрын
+bmoviestgams To control a motor, you can to use some sort of motor driver between the pi and the motor. The pi does not provide the current needed for a motor.
@bmoviestgams8 жыл бұрын
Thanks for your reply. It has an esc between the raspberry and the motor. Im still searching if you can help me in a way that i can controll the motor through the esc or with servohat for the raspberry maybe. Thanks anyway any help will be acceptable.
@mateus10pras145 жыл бұрын
My servo keeps rotating when i use the same code that you are using.
@aatifibrahimi85678 жыл бұрын
how can i generate a single clock pulse of 50 ms
@vardhamanvasawade20222 жыл бұрын
Plz send the code for the 360
@pharrell65328 жыл бұрын
Hi, I don't know why the program does not work in my Pi and my servo, I ve checked the pins blinking a led, I downloaded the GPIO libraries, neither the lesson 27 worked for me, I checked the servos in arduino, I know that the problem is the pwm, but I don't know how to fix it or what Im doing wrong. Very good vids, grettings from Mexico
@iswoo107 жыл бұрын
I'm having issues with servo-2.py. I followed everything the video said but I can't do the 180 degree turn. I get an error message File "servo-2.py", line 10, in time.sleep(.05) I've been following all the tutorials but I can't get to work. I have a Rpi ver 1 Model B. what am I doing wrong? please advise...
@yuangao97318 жыл бұрын
why is my servo jitter?
@TheBml1048 жыл бұрын
+高原 Mine jitters until pwm.cleanup() runs
@mikewhite909 жыл бұрын
Thanks for a Great tutorial, Best I've found so far, your enthusiasm really shines through and helped me no end with the "Scary maths". One thing I found is that my servo was quite "Twitchy" when it was supposed to be at rest, can we have a tutorial on the Pi's hardware PWM pin please
@mikewhite909 жыл бұрын
mike white Discovered Most of my "Twitchy judders" was due to a loose jumper wire on the GPIO pin, pinched them all a little tighter but yet to reassemble and test again, fairly confidant as worked Ok when I held the wires in contact, Would Still Love a tutorial on the Pi's PWM hardware channel though ;)
@georgebes35193 жыл бұрын
I want to control a servo from a remote control car, but it has five wires(brown, yellow, white, red, black). Which wire does what. Can someone help me please?
@AmirAli-yk4xb7 жыл бұрын
Hello Paul, Nice tutorial. I had a question for you how to make a servo motor to set on middle (90 D)
@invinity39828 жыл бұрын
please would you make a video where one can control more more than 1, forexample 3 servo motors with Raspberry pi. so in an application if the amount of rotation for motor 1 is 1 full cycle, then 2 full cycles for motor 2, and 3 full cycles for motor 3. i really love you teaching method, it is so motivating and easy to follow.
@gabrieljulioarmandosiagian19214 жыл бұрын
CMIIW, It can be concluded that the servo can be controled because its 3rd cable is connected into raspberry GPIO, am i right ?
@iswoo107 жыл бұрын
Never mind, I forgot to add import time. : )
@narayanasamythiruvengadam91557 жыл бұрын
Good Evening I want to use arduino as a Up counter with preset option using LCD. Any body help me to find out the suitable solution?.
@kalipc49104 жыл бұрын
Can you please do a lesson about stepper motor and raspberry pie. Please !!
@chrisklutts40965 жыл бұрын
def analysis(){ if (content == awesome) { subscriber++ ; print("You've got a new subscriber!") } } analysis(); console: You've got a new subscriber!
@freddyheryanto957 жыл бұрын
Nice tutorial, very helpful, easy to understand, thanks a lot! :)