Placeholder Image

Subtitles section Play video

  • please go to the line the computer guy dot com in order to view schematics, code and Maur for the projects that you are learning about Welcome back.

  • So in this video, I want to show you how to use a servo motor with an artery.

  • No.

  • So it's important.

  • Understand?

  • This is a server motor, not a normal electric motor.

  • What the difference here is is with a servo motor is you're able to tell it what position you wanted to go to.

  • So with a normal electric motor, you use those for vehicles.

  • You can have the vehicle go forward again.

  • A vehicle will backwards.

  • You can have the vehicle turn all of those types of things.

  • But basically all you can say is that the motor should either go forward or the motor should go backwards and how fast it should go with a servo motor.

  • What you're able to do is you you're able to tell it what position you want it to be in.

  • So I kind of think of a servo motor kind of like what you would see what they clock.

  • So you can say I want it at 12 o'clock position or I wanted at the nine o'clock position or I wanted at the three o'clock position us.

  • You're able to do things such as use.

  • This is some kind of like a steering wheel on a vehicle, or you're able to use this as some kind of like a manual display.

  • So maybe you want little flip cards to flip around based off of certain things.

  • So basically what a servo motor does is you're able to tell it that you want the motor to goto a specific position and then stay there until you want it to go somewhere else.

  • So with that, let's go over to the work bank so I can show you how to put this little project together.

  • Then I will show you the code, and I'll show you how it all comes together.

  • So here's a little project that's been put together.

  • There's really not a whole lot to it.

  • We have our standard Arduino, you know, bored.

  • And then we're using an Esther G 90 and micro servo motor.

  • Now, the important thing to remember about this particular servo motor is that it only has 180 degrees of rank.

  • So has 0 90 and then 180 so it can only go in an ark as such.

  • So as with that, basically all you need to do if you're gonna be using a servo motor is first you need to power it.

  • So we're just having little jumper wires running from the five of old and the ground.

  • So from a five goal and the ground, and then that goes to the power connector, the voltage connector and the ground on the adapter.

  • And then we're using digital pen eight, and that is going to the sensor wire here that's going to the white wire.

  • So basically, we have the power wires.

  • It's willpower, the motor.

  • And then the digital pen will tell this servo where it should be positioned.

  • So with that, let's go over and take a look at the code.

  • So here's a coat for this particular project.

  • Now the first thing that we need to do is we need to include at the servo library.

  • So this is the standard several library sorrow 0.8.

  • We included that first, the next thing we need to do is we need to define the servo pin so what digital pen is going to be communicating with the servo to tell it where it should be.

  • And so I have simply said digital pen at number eight be the pin that we're gonna be using today.

  • Then the next thing with a servo library is we actually have to create a servo that we will reference.

  • So we're gonna do here is we're going to say servo.

  • So we're creating a servo, and we're going to create a servo called servo one.

  • So this is how we will reference the servo that we're dealing with.

  • Then we're going to go down and we're going to do avoid set up.

  • So we're going to set up in the environment.

  • And so what we're gonna do with the servo here is what we're gonna say servo one dot attacks.

  • So we're going to use this attach function, and we're going to attack servo one to the servo pen.

  • So basically, all we're saying here is servo one is going to be at digital eight and then we have set up the environment.

  • Then all we gotta do is we're going to go down into a loop and for this loop All I want to do is I want to move, move the servo into different positions.

  • So we're going to go servo one.

  • So servo one dot Right?

  • We're going to say go to zero degrees.

  • So this is zero degrees.

  • Then we're going to delay for two seconds, 2000 milliseconds, then servo one dot right?

  • 45.

  • So that we were gonna go to the 45 degree delay for two seconds.

  • Servo one dot rate 90 delay for two seconds.

  • Server one dot rate 100 and 80.

  • So and then delay two seconds.

  • So all I'm going to do with this particular project is I'm simply going to move through at these different angles.

  • It is important, understand?

  • Doesn't have to be 45 could be 41 or 39 or 32.

  • Basically, you can position the servo motor to anywhere between 0 to 100 and 80 degrees, and you can also position the servo motor as a value of variable.

  • So let's say up here, you do some math, you come up with the angle.

  • You want the servo motor to be in.

  • You could actually plug in the value of a variable here, and then it will move to that particular position.

  • But this here, I'm just showing you I'm having it moved through these four different positions and then it will loop through just to give you the idea of how this works.

  • So let me upload this code to the Arduino, and I'll show you this in action.

  • So I've uploaded the code to the yard.

  • We know more or less as soon as I plug there and we know in it's going to start moving the servo motor around, so I haven't plugged it in yet.

  • Now, one thing just to make us a little easier visually is I have marked off this one signed with his little black indicator here.

  • And so there's black indicator will show you as as a servo motor moves around with that.

  • Let's plug this thing in and see how it works.

  • Yes, it's a zero.

  • Then it goes to 45.

  • Then it goes to 90.

  • Then it goes to 180.

  • Then it goes back to zero.

  • Then it goes to 45.

  • Then it goes to 90.

  • Then it goes under an 80 and there we go that's that's the excitement that we get for the day.

  • But this is basically what a servo motor allows you to dio is it allows you to position the motor into a specific position again, depending on what you're doing, Whether you're trying to make some kind of sign age or some kind of alert system when you're trying to steer a vehicle something like that, this allows you to move a motor to the specific position to do what you need done.

  • So that's really what there is to serve a motor.

  • So servo motors are motors that allow you to position them to specific angles again.

  • 0 35 45 90 So on and so forth.

  • You can use this in many, many different ways.

  • Now one of the things that I will warn you about, especially when you're dealing with inexpensive artery no projects, is it will come as a shock to you.

  • But when you deal with inexpensive little gadgets, they're not exactly the most accurate things in the world.

  • And so this is something that you should just keep in mind with your code s o.

  • I found that with this for some reason, if you said it to the zero angle it tries to overextend itself in a kind of theater is a little bit So if I was going to put this into her production vehicle or something instead of setting to zero, I might set it toe like one or two or four because there's something there's something wrong with a little sensor mechanism, and there when you tell him to go to zero, it actually tries to go too far.

  • On the other hand, with this particular servo motor, and they should be the same.

  • They're both SG nineties, but they're from different manufacturers with this particular one with the arm on here.

  • When I put the arm on it, it's ever so slightly off.

  • And so when I have, when I put this to t zero c zero should be like this.

  • But with this one with the arms, here is more like this, which means 45 more like this and nineties more like this in 180 is more like this.

  • So that's just something to be thinking about when you're going to be creating little projects.

  • Using the servo motors is always test your code on the actual finished product.

  • And just realize realistically, you may have to adjust the settings for the servo motor by a couple of degrees, one way or the other.

  • If it's supposed to be at 90 degrees, you may end up having to put it at 93 degrees or 87 degrees.

  • Seven.

  • It lines up perfectly.

  • If you simply write, you know, one sketch and then deploy it to 100 different servers.

  • I will guarantee you you'll probably get 100 different results, at least when you're using inexpensive again.

  • If you're talking about the servo motors, I think you're going for like 2 to $3 apiece.

  • So when you're dealing with 2 to $3 servo motors, just keep this in mind.

  • If you're dealing with 30 or $50 servo motors.

  • It's probably not such a big deal, but again, especially at your level.

  • If you're walking this type of video, just keep in mind.

  • When you write the code, you may have to adjust again.

  • Instead of making it zero, you might have to make it two or three instead of making it 90 you might have to make it 87 all based off of how well the sensors are calibrated within the servo.

  • And then just physically how everything fits together.

  • Yes, $3 gadgets are made like, well, $3 gadgets.

  • So, as always, I enjoy doing this video and look forward to seeing the next door.

please go to the line the computer guy dot com in order to view schematics, code and Maur for the projects that you are learning about Welcome back.

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it