In this tutorial, we will learn how to interface a servo motor using Arduino UNO.
The motor inside the setup of a servo is attached by gears to the control wheel. When the motor rotates, the potentiometer’s resistance changes hence the control circuit can precisely regulate how much movement there is and in which direction.
The motor’s speed is proportional to the difference between its actual position and desired position. When the shaft is near the desired position it turns slowly else fast. This is called proportional control.
They are controlled by sending PWM (pulse width modulated) signals through the control wire.
They are available in many sizes and are of three types - Positional rotation
- Continuous rotation
- Linear
So now we are familiar with the motor let us interface it
Components Required:
After making the circuit dump the code given below.
#include <Servo.h>
Servo myservo;
int pos = 0;
void setup()
Components Required:
- Servo motor 1No
- Arduino UNO 1No
- Few connecting wires
- Breadboard
#include <Servo.h>
Servo myservo;
int pos = 0;
void setup()
{
myservo.attach(9);
}
void loop()
myservo.attach(9);
}
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);
}
for (pos = 180; pos >= 0; pos -= 1)
{
myservo.write(pos);
delay(15);
}
}
Servo motors are used in making joints of robots.
So try something out and let us know what you made in the comment section.
Two variants of servos are available one which rotates 180 degrees and other which rotates 360 degrees.
You can modify your servo motor to increase the rotation range just follow the link below.
http://www.instructables.com/id/How-to-modify-a-servo-motor-for-continuous-rotatio/
myservo.write(pos);
delay(15);
}
}
This was the normal interfacing; you can also control the movement with the help of a potentiometer as shown below.
Servo motors can be used for several applications few of them are: Servo motors are used in making joints of robots.
- Surveillance cameras.
- Door opening mechanisms.
- Solar tracking systems.
Two variants of servos are available one which rotates 180 degrees and other which rotates 360 degrees.
You can modify your servo motor to increase the rotation range just follow the link below.
http://www.instructables.com/id/How-to-modify-a-servo-motor-for-continuous-rotatio/
Thinking ?
Join our hands-on training courses.
To know more visit us at http://www.sudolearn.com/
Comments