Introduction

In this course we’ll look at how to control a servomotor with the Raspberry Pi.
A servomotor is a very precise motor where you can control its direction and angle to the nearest degree. It can be used if you have a project requiring very precise motor positions. Some servomotors can make turns of up to 180 degrees. If you need a precise motor turning 360 degrees, we recommend a stepper motor.
Here’s the diagram for connecting the servomotor to the Raspberry Pi:

Programming

Here’s the program to operate the servomotor. It uses PWM to vary the motor position: