Introduction
 
In this article I will explain the working of a servo motor. It will work according to the rotating method and the system can be used for door locking purposes.
 
Parts
 
     - Servo
- Arduino Mega 2560
- HookUp Wires
 
  Figure 1: Servo
     - It is small and cost-effective.
- It is used for small robotics and radio controls. 
 
Connection 
     - The servo first pin can be connected to the Gnd
- The second pin can be connected to the Vcc
- The Third pin can be connected to the digital pin 09 of the Arduino Mega 2560.
 
Programming
     - #include <Servo.h>    
- Servo myservo;    
- void setup()    
- {    
-   myservo.attach(9);    
- }    
- void loop(){    
-   myservo.write(0);       
-   delay(1000);            
-   myservo.write(90);      
-   delay(1000);            
-   myservo.write(180);     
-   delay(1000);            
-   myservo.write(90);      
-   delay(1000);            
- }    
 
 
Explanation
     - The servo can work in the condition of the degree.
- It can first rotate in the 0 degree
- Then 90, 180, and it will automatically return to 90 degree.
 
Output:
 
 Figure 2: Output
 
Read more articles on Arduino: