Introduction: Servo Motor Control Using Raspberry Pi and BLYNK APP

In this tutorial, we will learn how to interface Servo motor with the Raspberry pi module and operate it with the Blynk app. and  This project I will try to show you very easy and beautiful step-by-step. If you start this project with me then I believe you can complete it too. It is a very simple process. Below is a list of all the components you need to complete this project

Required components Servo motor control using Raspberry Pi and BLYNK APP

    1. Raspberry pi
    1. Servo Motor
    1. Connecting Wires
    1. Power Supply
This book will help you to know more about raspberry pi 20 Easy Raspberry Pi Projects Software
I will try to give you a brief idea about the components required for this project. If you want to know more about this vibration, you can find out by searching on Google.

Raspberry pi

The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing and to learn how to program in languages like Scratch and Python. It’s capable of doing everything you’d expect a desktop computer to do, from browsing the internet and playing high-definition video, to making spreadsheets, word-processing, and playing games. What’s more, the Raspberry Pi has the ability to interact with the outside world and has been used in a wide array of digital maker projects, from music machines and parent detectors to weather stations and tweeting birdhouses with infra-red cameras. We want to see the Raspberry Pi being used by kids all over the world to learn to program and understand how computers work. Source: What is a Raspberry Pi?

Servo Motor:

A servo motor is an electrical device that can push or rotate an object with great precision. If you want to rotate and object at some specific angles or distance, then you use a servo motor. It is just made up of a simple motor that runs through a servo mechanism. If the motor is used is DC powered then it is called DC servo motor, and if it is AC powered motor then it is called an AC servo motor. We can get a very high torque servo motor in small and lightweight packages. Due to these features, they are being used in many applications like toy cars, RC helicopters, and planes, Robotics, Machine, etc. [caption id="attachment_380" align="alignnone" width="300"] MG996R-Servo-Motor-Pinout[/caption] Servo motors have three wires two will be used for Supply (positive and negative) and one will be used for the signal that is to be sent from the Raspberry pi or Any MCU. Servo motor is controlled by PWM (Pulse with Modulation) which is provided by the control wires. There is a minimum pulse, a maximum pulse, and a repetition rate. Servo motor can turn 90 degrees from either direction from its neutral position. The servo motor expects to see a pulse every 20 milliseconds (ms) and the length of the pulse will determine how far the motor turns. Servo motor works on the PWM (Pulse width modulation) principle, which means its angle of rotation is controlled by the duration of applied pulse to its Control PIN.  Servo motor can be rotated from 0 to 180 degrees, but it can go up to 210 degrees, depending on the manufacturing. This degree of rotation can be controlled by applying the Electrical Pulse of proper width, to its Control pin. Servo checks the pulse every 20 milliseconds. The pulse of 1 ms (1 millisecond) width can rotate the servo to 0 degrees, 1.5ms can rotate to 90 degrees (neutral position) and 2 ms pulse can rotate it to 180 degrees.  All servo motors work directly with your +5V supply rails but we have to be careful on the amount of current the motor would consume, 
What is Blynk APP
BLYNK APP the most popular IoT platform to connect your devices to the cloud, design apps to control them, analyze telemetry data, and manage your deployed products at the scale you can download from google play store

Circuit Diagram

[caption id="attachment_339" align="alignnone" width="300"] PIR Raspberry pi4_SERVO[/caption]
In this project, we used raspberry pi4 and raspberry pi4 all pin is not PWM Pin only  2 are  PWM pin  But I have connected the PWM pin of Servo with Physical Pin GPIO12  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 GPIO12 of Raspberry.
Once the circuit diagram is complete, you will need to create a BLYNK account. How to create an account and how to make this account suitable for servo motor control.

BLYNK account

First, you need to download Blink Apa from Google Play Store and open it and create an account with an email and password. Here you need to create an account with an email address and password. What else is an account? When you log in, you will see an interface like this flow in this video. [caption id="attachment_385" align="alignnone" width="136"] how to create blynk account[/caption] Now an email has been sent to your email account This is very important because you need to interface the Blink app with Raspberry Pi.  using this key while programming. so you need to save the key, otherwise, the program will not work. Code: Servo motor control using Raspberry Pi and BLYNK APP
import RPi.GPIO as GPIO
import blynklib
import time

GPIO.setup(11, GPIO.OUT)


auth_token = 'vbKmyZo2zYFHe1GqoYbgDZk0n5RfsxYI'

# Initialize Blynk

blynk = blynklib.Blynk(auth_token)

@blynk.handle_event('write V0')
def write_handler_pin_handler(pin, value):
    Doorlock = (format(value[0]))
    if Doorlock =="0":
        print("Door Locked")
    elif Doorlock =="1":
        print("Door Unlocked")
    while True:

except KeyboardInterrupt:

# Reset GPIO settings
Raspberry Pi Project:

How to interface servo motor with Raspberry pi

PIR Motion Sensor using Raspberry Pi4 | Interfacing TutorialPIR Sensor -Email Sending Movement Detector using IFTTTControlling a DC Motor with Raspberry Pi4How to Use the Raspberry Pi4 Camera And PIR Sensor to Send EmailsRaspberry Pi Distance Sensor using the JSN-SR04THow to connect 16×2 LCD with Raspberry piHow to interface RFID-RC522 with Raspberry Pi