Servo Motor SG-90 Interfacing
with Arduino Uno
By Engr.Habib Ur Rehman
Components/Equipment Required:
Following Components/Equipment are
required to perform task.
1.
Arduino
Uno(https://piees.pk/product/arduino-uno-r3/)
2.
Servo
Motor SG-90 (https://piees.pk/product/sg-90-servo-motor/)
3.
Breadboard
4.
Jumper
Wires (https://piees.pk/product-category/jumper-wires/)
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);
}
}