Sunday, May 17, 2020

Servo Motor SG-90 Interfacing with Arduino Uno By Engr.Habib Ur Rehman


 
                  Servo Motor SG-90 Interfacing
                  with Arduino Uno
                 By Engr.Habib Ur Rehman

Components/Equipment Required:
            Following Components/Equipment are required to perform task.
2.    Servo Motor SG-90 (https://piees.pk/product/sg-90-servo-motor/)
3.    Breadboard
Circuit Diagram:
Arduino Program:
#include <Servo.h>
int servoPin = 9;
Servo servo; 
int servoAngle = 0;
void setup()
{
  servo.attach(servoPin);
}
void loop()
{
   servo.write(45);
   delay(1000);
   servo.write(90);
   delay(1000);
   servo.write(135);
   delay(1000);
   servo.write(90);
   delay(1000);
  {                                 
    servo.write(servoAngle);             
    delay(50);                 
  }
  for(servoAngle = 180; servoAngle > 0; servoAngle--)
  {                                
    servo.write(servoAngle);         
    delay(10);     
  }
}

No comments:

Post a Comment