- [Narrator] With a servo motor,
you don't just give it electricity
and have it spin endlessly.
You also need to give it a control signal
which says to which angle the driveshaft
on the servo should rotate.
Tell it to rotate to 180 degrees, it will.
Tell it to rotate to 20 degrees
and it'll go 160 degrees back the other way.
Also, most servos don't rotate freely over 360 degrees
like a normal motor.
The simplest way to use a servo motor is to have it set
to it's minimum, median and maximum values using code.
Remember though, servo motors are not particularly powerful
and won't be able to lift large loads.
To connect a servo motor to your Raspberry Pi,
find the three jumper wires extending from it.
Different makes have different colored wires
but you can be fairly safe in assuming that the five volt
or power wire will be red
and you should connect that to pin two.
The ground wire will be black or somethings brown
and can be connect to any pin marked GND
on your Raspberry Pi.
The remaining wire will be your signal wire,
which you can attach to any numbered pin.
Just remember which pin you are using for your code,
if you don't copy the diagram shown here.
In this example, we have wired the servo to pin 17.
Once you have wired your servo to the Raspberry Pi
you can test it's working with this script.