INTERFACE SERVO MOTOR WITH ARDUINO UNO

INTERFACE SERVO MOTOR WITH  ARDUINO UNO

Interface servo motor with Arduino Uno


You want to make robot, Automatic steering movement of rc car, plane and gimbal etc. Then you should know about the servo motor.
And you can make easily  to these types of projects with the help of servo motor.If you want read previous article click on this link. 

What is servo motor?

Servo motor



Servo motor is types of motor that can rotate for desire position of motor . You can say another way servo motor is closed loop control system.
control system uses position feedback signal to adjust the rotate and direction of motor for achieve of desire result. 
The servo motor works on same principle.  Generally this type of motor consists of motor and motor is connected to output shaft through the gear and motor drives the shaft .And shaft drives the servo arm where servo arm connected through the potentiometer 
and potentiometer provide the feedback signal  to the control unit for current position of motor where control unit compare the feedback signal of current position of motor for exact position.

how servo motor work?

Servo motor controlled by pwm signal sending through the micro controller or other pwm provider circuits.
servo motor expect to receive the pwm signal every  20ms with 50 Hz frequency.

 when pwm signal is high for 1ms then the angle of servo motor will be rotate zero degree.


when pwm signal is  high for 1.5ms then the angle of servo motor will be rotate 90 degree.


 when pwm signal is  high for 2ms then the angle of servo motor will be rotate 180 degree.

Pin out of servo motor


Pin out of servo motor



 Red wire   - 5V power supply.

Brown wire  - Ground(GND).  

Yellow wire  - Signal.  

Schematics Diagram:- 


Schematics diagram of servo motor and Arduino Uno


Circuit Diagram:-


Circuit diagram of servo motor and Arduino Uno


Component Required:-

  • Arduino Uno
  • Micro servo 9g.
  • 9v Battery.
  • Some Jumper wires.

Interface Servo motor with Arduino Uno

Servo  - Arduino Uno

 5V          - 5V
Ground   - Ground
Signal     - D2


Here Yellow wire of servo motor is a signal pin. So signal pin of servo motor is connected to digital pin D2 of Arduino Uno and red wire of servo motor is 5v power supply. So 5v power supply pin is connected to 5v pin of Arduino Uno. And also brown wire of servo motor is ground pin. So ground pin of servo motor is connected to Ground pin of Arduino Uno.

Code:-  

After servo motor and Arduino Uno interface successfully. Then firstly you will open the Arduino ide on your computer. Because you will need servo library. 
Go to ->sketch ->go to ->include library ->manage libraries and you will have to type servo on search panel and enter then wait some second and show servo library then install it. 
Then go to -> file -> Examples -> Servo ->sweep
   
/* Sweep*/
#include <Servo.h>
Servo myservo; 
int pos = 0;   
void setup() 
{
  myservo.attach(2); 
}
void loop() 
{
  for (pos = 0; pos <= 180; pos += 1)
 { 
    
    myservo.write(pos);            
    delay(15);                     
  }
  for (pos = 180; pos >= 0; pos -= 1) 
{  
    myservo.write(pos);              
    delay(15);                       
  }
}
                                    

Post a Comment

0 Comments