fbpx

Interface Servo Motor With Arduino Uno

Some special types of application of electrical motor where rotation of the motor is required for just at certain angle not continuously for long period of time.

  • Motor are required with some special arrangement which makes the motor to rotate at certain angle for a given electrical input (signal).
  • Servo motor use servo mechanism.
  • It is a closed loop mechanism that uses position feedback to control the precise angular position of the shaft.
  • Servo motors have three wires.
  • Two of them are red and black which is used to give power to the motor.
  • The third wire is used to provide control signal for angular position.
  • It uses Pulse Width Modulated (PWM) waves as control signals.
  • The angle of rotation is determined by the width of the pulse at the control pin.

Hardware Required

  • Servo Motor.
  • Arduino.

Circuit

Code

 int servopin = 13;
 void setup()
 {
   pinMode(servopin,OUTPUT);
 }
 void loop()
 {
  digitalWrite(servopin,HIGH);
  delayMicroseconds(500); // 0 Degrees
  digitalWrite(servopin,LOW);
  delay(20);
  digitalWrite(servopin,HIGH);
  delayMicroseconds(1500); // 90 Degrees
  digitalWrite(servopin,LOW);
  delay(20);
  digitalWrite(servopin,HIGH);
  delayMicroseconds(2500); // 180 Degrees
  digitalWrite(servopin,LOW);
  delay(20);
 }

Leave a Reply

Your email address will not be published. Required fields are marked *