All right.
And let's finish this section with a servo motor.
And just after that, we are going to practice with the Arduino components, the serial communication
and the Raspberry Pi.
So I'm going to add a servo here.
So a micro servo.
Okay, let's actually flip it.
Like that.
Okay, So on a classic hobby servo motor you will have here, you will see three different pins, okay?
And three wires.
So you will have a brown one, a red one and an orange one or something that is similar.
So the brown one corresponds to the ground.
So we are going to first connect the ground to the ground of the Arduino.
So let's connect to the common ground here.
Let's put that in black and then we have power.
So power we can give five volt here and let's go here.
That's going to be red.
And then we have the signal.
So the signal is basically to be connected to a digital pin.
I'm going to use 12.
So for this digital pin, you don't need any pin or any special pin, just any digital pin will do.
And let's use a different color.
Let's use brown.
Okay.
And that's it for the servo motor.
But I'm going to explain you something a bit extra here.
So here what you're doing is you're going to control the servo motor with PIN number 12.
So that's going to give the command to the servo.
But the servo is powered.
Okay.
From the Arduino.
Also, the thing is that the servo motor, so if you use a hobby one, a standard one, it's completely
fine.
It's going to be powered on from the Arduino.
Okay.
That's obvious here.
But the servo may draw more power than other components.
So if you want to add multiple servers or give more strength to the servo, you may also want to add
an external power supply.
So I'm just going to show you.
So I'm just going to use this nine volt battery here just as an example.
So yours is not going to be that one that can be any other power supply.
But basically what you can do is you can see when you have an external power supply, you have a negative
and a positive.
So let's actually connect these two to this side of the breadboard.
Okay, So I'm going to put that in black and that in red.
So now we have this side of the breadboard with the ground connected to the Arduino here, the line
with five volts and now the other side here.
So the, the piezo here is not in this.
Okay?
It's just on top, but it's just a visual.
So you have another line with another ground and another plus line, which is this time the external
power supply.
And what you can do is that instead you can just power on the servo.
So I'm just going to do this.
So put the ground here and then the power supply is going to come from.
The.
External power supply.
Okay.
And one very important thing to do is to actually connect the grounds of everything, okay?
Because if you don't connect the ground of everything, then the comment you're going to send here on
PIN number 12 is not going to work.
It's going to be some garbage comment.
So you're going to connect the ground of this to the ground of the.
Arduino.
Make sure you connect the ground, okay.
And not the ground to the VCC because you may have some problems.
Okay.
And now you have the same servomotor.
You can give the same command, but it's externally powered by another battery or another power supply.
So all the grounds are connected.
Everything here is powered by the Arduino.
The servo motor is powered by this.
Okay.
And then we still have the command from PIN number 12 that goes to the servo motor.
And just one last thing is don't use PIN number 13 here on the Arduino Uno because PIN number 13 is
also connected to the built in Led.
And if you connect anything to that, well, you may have some unexpected behavior because this pin
is going to be triggered automatically at some point.
So just don't use the PIN number 13.
So you can use PIN 2 to 12 on Arduino Uno because those ones are reserved.
Better to reserve them for serial communication and this for the built in Led.
All right.
And that's it for the circuit.
Then here is the real circuit with the servo motor.
You can see here, I use a very small one and the gear is in a plastic here.
Okay, that's very low quality one, but that's going to do for this course.
That's basically the standard one, the cheapest you can find and maybe the one you have on your Arduino
kit.
And you can see I have some kind of stuff like this that I'm going to use on the servo for the final
project.
So you can see we have this wire here.
So this cable with a brown, red and orange, So brown and red are connected here to ground and five
volt of the Arduino.
I'm not going to use an external power supply.
I'm just going to power the servo from the Arduino.
This is completely fine.
Okay.
For this circuit.
It's just that if you want more servo or if you want to use that in a real application where you need
to put a lot of torque.
Okay.
On the servo.
So a lot of force on the servo.
Maybe use an external power supply.
So here I've just moved a bit the ground and the five volt line here on the right so I can put the servo
here on the left.
And then this is connected to PIN number 12.
Okay.
Just to show you, I have another servo so you can see that's completely different here about another
one.
And the gear here is in metal.
And you can see when you buy a servo, usually you have stuff like this that comes with it.
Okay, So you can just plug this to the servo so you can basically plug the servo to something mechanical,
for example, a door mechanism or anything like a camera, anything that you want.
So you can plug the servo here with the mechanical part with those tools here and you can see any hobby.
Servo Well has the same.
Okay, same connector.
So I'm maybe going to use that one for the rest of the course, but that's the exact same servo.