Interface SG90 servo motor with Arduino

What is the SG90 Servo motor?

It is a tiny and lightweight servo motor with high output power. It is a rotary or a linear actuator that is used for precise control of an angular motion. It is also known as a closed-loop system. It consists of a motor that is coupled with a sensor (a potentiometer) for position feedback. The feedback is feed to the IC which is present inside the servo and the IC uses the feedback values for controlling the precise movement of the servo motor. This servo motor can approximately rotate up to 180 degrees. It uses PWM(Pulse Width Modulation)  which has a pulse cycle of 20ms at 50Hz. 

Pin configuration of SG90 servo motor

SG90 Servo motor pin diagram

Features of SG90 servo motor

  • The operating voltage is between 4.8 to 6 volts.
  • The maximum current consumption is <600mA
  • The operating temperature is between -10°C to 50°C.
  • The rotational angle is between 0° to 180°.
  • The torque is 1.8 Kg/cm at 4.8 volts and 2.5Kg/cm at 6 volts. 

Components needed

  • Arduino UNO
  • SG90 servo motor
  • Jumper wires 

Pin connections of SG90 servo motor with Arduino UNO

  • Connect the VCC wire of the servo motor to the 5-volt pin of the Arduino UNO board.
  • Connect the GND wire of the servo motor to the GND pin of the Arduino UNO board.
  • Connect the signal pin of the servo motor to the D5 pin of the Arduino UNO board.

Circuit diagram of SG90 servo motor with Arduino

SG90 Servo motor circuit diagram

Arduino code for SG90 servo motor

#include "Servo.h"// Include the library for the servo
const int servoPin = 5;// Define the signal pin of the servo pin
Servo Servo1;// Create an object of type servo to access all the functions of the library
 
void setup() {  
   Servo1.attach(servoPin);// Attach the servo pin
   Serial.begin(9600);// Set baud rate for serial communication
}
void loop(){ 
   
   Servo1.write(0);// Set angle using the write() function
   delay(100); 
   Servo1.write(90);
   delay(100);
   Servo1.write(180);
   delay(100); 
}

Leave a Reply