Activa JavaScript para disfrutar de los vídeos de la Mediateca.
Arduino: servo - Contenido educativo
Ajuste de pantallaEl ajuste de pantalla se aprecia al ver el vídeo en pantalla completa. Elige la presentación que más te guste:
Hello, in this video tutorial I'm going to show to you how to use a servo motor.
00:00:00
This type of motor, you can see it here, they are not the usual type of motors that they turn and turn and turn.
00:00:08
They work in a different way.
00:00:16
Using one block like this one, can you see it?
00:00:18
can you see it? Girar servo en el pasador 10 a cero grados. Using this block, we can send an order,
00:00:22
a command, to the servo, this one, connected to number 10, and the command, instead of being
00:00:29
turning and turning, is saying that the servo has to place itself in zero degrees position.
00:00:35
For instance, here the servo is in zero degrees, this is zero. Okay, so the servo is connected,
00:00:43
The green wire, the one on the left, is connected here, for instance, to number 10, or 11, or 9, whatever you prefer.
00:00:50
And there are also two other connectors.
00:01:01
The red one, the one in the middle, is connected to the power source, and the one on the right is connected to ground.
00:01:04
Here, we have an extra component.
00:01:11
Can you see it?
00:01:13
This is a power supply.
00:01:14
The servo motor is here, so you can click and drag, but if you look for the power source, you can't find it here.
00:01:15
You will have to look in the standard library, the one that has all the components.
00:01:27
The moment we are looking for every component, todos, if we move down, down and down and down, here we have the power source.
00:01:35
So we click and drag.
00:01:47
The reason we need a power source is that the Arduino board that is here can't provide enough energy to the servo motor.
00:01:49
But anyway, the Arduino board needs the ground.
00:01:59
The ground is connected to the ground. The ground of the Arduino board is connected to the ground of the servo motor and to the ground of the power source.
00:02:04
This way, the three of them have a common point of reference.
00:02:11
This is also the idea of the ground. It's a reference of voltage.
00:02:15
It's not just the way we close the circuit, that is true, but it's also a common point of reference for voltage.
00:02:19
So, now I think you understand why the red wire is connected here and why the black wire is connected here.
00:02:27
Because the power to move the servo is going to be provided by the power source, okay?
00:02:34
So, the program you will have to create, okay, I repeat, before, I repeat, I'm not going to show the code today.
00:02:41
I'm going to send, I'm going to show you how the program behaves.
00:02:52
I'm going to start the simulation.
00:02:55
The program starts here, starts here, and it will be turning and turning and turning,
00:02:57
because we are always sending commands to make the motor be in different positions.
00:03:03
So we have started in 0 degrees, we are moving up and up and up,
00:03:11
and the moment we are in 90 degrees, we start moving down, 90, 85, 80, 75, 70,
00:03:16
70, and the program will finish in zero degrees again, okay?
00:03:24
This is the intensity, can you see?
00:03:29
That is providing the power source, okay?
00:03:31
At the moment we arrive to zero degrees, the program will stop, okay?
00:03:35
It doesn't move anymore.
00:03:39
We can't stop it anyway.
00:03:41
So, the first thing you need to do is connecting the circuit this way.
00:03:42
They are doing a board, the servo, and the power source.
00:03:46
And I hope you are understanding why the power source is needed.
00:03:50
And the blocks, I'm not going to show them to you,
00:03:55
but I'm going to show the main idea.
00:03:59
The first thing we need is a block like this one.
00:04:04
With this block, you are saying that the servo connected to number 10
00:04:07
is going to be in zero degrees.
00:04:11
Okay, this is the way we start.
00:04:14
We always need to start somewhere.
00:04:16
We always need to be sure that our servo will start in the desired position
00:04:19
because we don't know, usually we don't know where it will be.
00:04:25
It will be forever in 45 or 50 or 30, I don't know.
00:04:28
So the first order is always start in zero degrees.
00:04:32
Then we will have to wait, for instance, one second.
00:04:37
Every time we make the servo turn, we need to wait some time.
00:04:40
We need to give time to the servo to move.
00:04:47
Okay, so this is the first part of the code.
00:04:51
Then there will be a second part that will be something like that.
00:04:53
This part is taken from the previous exercise, okay?
00:04:58
This is not the one we are going to use to move the servo, but it's going to be really similar.
00:05:02
The first time you will move upwards, you will, for instance, turn or jump every 5 degrees from 0 to 90, okay?
00:05:05
Remember the simulation you have for racing?
00:05:18
And then you will send the order to move, and again, we will use a variable.
00:05:21
The same way we use the variable to send a frequency to the buzzer, we will use a variable to send an angle to the servo.
00:05:25
Again, we will have to wait to give time, so this one will be the second part of the program, and there will be a third part, really similar to the second one.
00:05:40
But instead of moving upwards, we will move downwards.
00:05:49
Again, we will jump every 5 degrees from 90 to 0.
00:05:53
And again, we will send commands to the servo using a variable.
00:05:59
A variable, for instance, for angle.
00:06:04
And then every time we make it move, we will wait for one second.
00:06:06
So this is the program you will need.
00:06:10
The first part, something similar to this one for the second part,
00:06:12
and something similar to this one for the third part.
00:06:16
And if you program it properly, it will behave the same way you have seen in the simulation, okay?
00:06:19
The exercise is not difficult.
00:06:26
Just follow my instruction, okay?
00:06:28
So, good luck.
00:06:31
- Autor/es:
- David Gonzalez Arroyo
- Subido por:
- David G.
- Licencia:
- Reconocimiento - No comercial - Compartir igual
- Visualizaciones:
- 258
- Fecha:
- 10 de enero de 2021 - 18:31
- Visibilidad:
- Público
- Centro:
- IES MARIE CURIE Loeches
- Duración:
- 06′ 32″
- Relación de aspecto:
- 1.78:1
- Resolución:
- 1920x1080 píxeles
- Tamaño:
- 17.14 MBytes