How to interface servo motor with Raspberry pi

In this project, we will Know about How to interface servo motor with Raspberry pi  For this project, we will be using the Raspberry Pi 4  and Tower Pro MG995 Servo Motor.

Below is a list of all the components you need to complete this project

Components Required

1. Raspberry Pi

This book will help you to know more about raspberry pi
20 Easy Raspberry Pi Projects
For this project, you have to need to know a technics PWM, In the PWM technique, you will be sending a pulse of variable width and the position of the Servo Motor’s shaft will be set by the width or length of the Pulse.

The frequency of the PWM signal is a fixed value and is dependent on the type of Servo Motor. For this project, MG995 Servo Motors have a PWM frequency of 50Hz.
For know more about This servo MG995 reed Datasheet in this link

At 50Hz i.e. a period of 20ms, the minimum pulse width is 1ms and the maximum pulse width is 2ms. Most servo motors can have a swept area of 180 degrees i.e. 90 degrees on either side of the neutral position

Raspberry pi PWM
Raspberry pi PWM

Servo(MG995) Interfacing with Raspberry pi

PIR Raspberry pi4_SERVO
PIR Raspberry pi4_SERVO

In this project, we used raspberry pi4 and raspberry pi4 all pin is not PWM Pin only  4 are  PWM pin  But I have connected the PWM pin of Servo with Physical Pin 22  of Raspberry Pi4 Connect the VCC and GND of the  MG995 Servo Motor to +5V and GND pins of the power supply. Then connect the PWM Pin of the Servo Motor to Physical Pin 22 of Raspberry.

Make the ground common between Raspberry Pi and the Power Supply of the Servo Motor

Servo Motor Control Python Code

Rotating 180 degrees in 10 steps  Loop to allow user to set servo angle 

My previous tutorial

 136 total views,  1 views today