let's learn about the servo Motors it's model airplane or a Servo motor is used
as a steering to control this RC car or Servo is used in RC boat
this course is based on sun founder three in one Arduino kit sold on Amazon everything that
you learn in this course is included in this kit the course comes with tons of components
and projects all with instruction and video for smart car and other projects that you
can use for school or home automation you can purchase it from sunfounder.com
the kit also comes with full documentation code download learning projects with full
explanation wiring diagram and the code that you can download a link to purchase the kit
and documentation is below the video in the description welcome to Arduino course by Robojax
for RC boat you can control the direction and altitude of RC plane
and here you can see that the two servers used here to control the direction of this RC plane
and this robotic arm server is used for a hand grip and also you see here one Servo another Servo
another Servo another Servo to rotate this robotic arm in different direction up and down left to
right and fix different directions this is a Servo motor also this is very large with comparing to
this micro Servo I'm gonna display this one the amount of torque that each generate will
determine the quality and the price of the servo and also the size for example this can be used for
the steering of a very powerful or thick car but this would be for small airplane or a small RC car
when you purchase it usually they ship it with this half arm or maybe this type of arm or that
type of arm that doesn't have this so these can be used for different purposes and you can attach and
you can detach them and put them at any direction and using Arduino or other means either RC remote
control you can change the direction of the servo and from inside you can also see the gear
or you might attach this small arm for different purpose like this
a Servo has three wires for example in this Servo the middle pin is always the power wire in this
case this server is 5 volts and you have to look at the data sheet of the servo to get and check it
what is the voltage usually it's 5 volts by 6 and other voltages are available this Servo is 5 volts
and the middle this is a positive this darker color is the ground they put the positive at the
middle because even if you connect it incorrectly or inserted in different position the middle is
always positive so the device is protected against the incorrect polarity the last one is a signal
that you control the servo from here you send the signal it'll have a motor inside the servo motor
and this rotates 180 degrees servos will come with different arms that can be attached to it
for example you can attach some if you need to control two parts of something you can connect
a string or a rod here through these holes or here and or maybe I'll adjust it at different values at
different length from the center so this is called the radius and this will be attached
and then there will be a screw that you can see I'm moving it with hand
so if you just remember this point now it just goes 180 degrees so it can come back
but it doesn't go full rotation just need if you don't need the other side you can just
use this one so the servo is very useful for a lot of application in robotics
here is the wiring using first thing this is a Servo motor connected to Arduino
the signal wire have been connected to pin 9 the middle wire which is a VCC or power have
been connected to 5 volts and the ground have been connected to the ground now let
me explain the wiring this is called the servo connector which has three pins and this is the
female type and there are also the male type of this but the servo that you receive always will
have this female connected now I'm connecting it to this three wires the DuPont mail to mail
here this is the ground the wire that I put is blue and this is connected to the ground
of Arduino and the middle one the green is the power which is and here that is connected here
to five volts of Arduino and the left pin which is the signal for Arduino this is connected to pin 9.
to run Servo or control it click on file example and scroll down until you see servo
and here there is one sweep one is Knob let's open first The Sweep
including the servo.h Ed header file and this is used to control the servo
and then you put the name of the header file this is a class and
this is you're creating an instance of the class and here it's called My servo
and the next line integer pose that's a position that's a variable that's holding the position and
initial position is zero and inside the setup we have to attach the servo to the
um program my Servo the same name that you have here my Servo dot attach nine in this case this
example shows that the servo is connected to pin 9. and if you have multiple servers you just put
this line in the next one and then change this number different pin and inside the loop here that
starts from here to here we have a for Loop one for Loop and then another for Loop this for Loop
checks the position initially at zero and this is for comparison it Compares that position is
if it's smaller than or equal 180 then Position will be incremented by one and then my Servo dot
right when you put dot right this moves the servo to the position that you put here because this
position is this is a loop and increments one by one it starts from zero and goes up to 180
so this value is changing between 0 to 180. and when this is sent to the server Servo moves to
that position in terms of degree and then wait for 5 15 milliseconds, so the server have enough time
to move and then it continues again and moves at one more degree increasing from zero to 180.
when it reaches 180 and then exits now this then this Loops take effect initial position of this
one is 180 and it checks if it's bigger than 0 which is true and then that it's subtracting the
value decrementing it and initially it writes at 180 because this was 180 now it trace it at 180
and then comes back subtract this is become 179 178 77 and so forth until it reaches 0 then the
loop exits a Servo have been moved back to the position zero this starts from 0 to 180
and here it starts from 180 to 0. it comes back it does the same thing all over again
now I will upload the code I'm uploading the code once the code is uploaded this
will continuously start rotating let's see when the upload is finished you will see the blanks
okay so this side is 180 and this side is zero I can remove and put it properly
now I've put it trash that this is 0 and that is 180
and this is the code that it controls it because this is a loop in your application you will not
read it this is just for learning purpose so you will use this one to set the servo
at any angle you want, I'm now deleting this put it like this for example 90 degrees upload
so, it turned to 90 degrees if I wanted to zero degrees let me upload it
now it says zero so the zero for the servo is in here
if I put 180 it should turn in this area and wait
this way you can control a Servo motor with any angle that you want,
and it rotates up to here that's 90 that's 180 so if 90 is here 120 should be somewhere in here
now I'm bringing back this code and this time instead of one let's move it 20 degrees clockwise
from 0 to 180 that is 0 and 280 so we say go 20 20 and it will not reach 180 but when it goes back,
we say go five degrees because this is a step or increments let me upload it
now this is very fast, and it doesn't give enough time let's give it a little time
100 millisecond and give it also 100 milliseconds
now we see from this side it goes five from here it goes 20.
reaches very quick before it was not able to do it because 15 milliseconds was too fast,
and it was just stacking in this area now it goes a full Direction you see this is very
smooth because it goes fine now here is fast five five five five and then 20 20. you can go even
60 degrees like by three move it should reach there and make this
25 degrees you see three move was then the other way and this is 25
degrees now one two three because I said 60 to 60 times 3 is 180.
this is 20 degrees each 25 and that is now six and here is the example of another Servo motor
[Music]
foreign [Music]