INTERFACING SERVO MOTOR WITH ARDUINO
Experiment No:
AIM:To interface the Ultrasonic sensor and Arduino to measure the Distance.
Components Required:
1) Power supply
2) Arduino Interfacing board
3) Servo motor interfacing kit
4) Connecting wires
Description:
A servo motor is an electromechanical device that produces torque and velocity
based on the supplied current and voltage. A servo motor works as part of a closed
loop system providing torque and velocity as commanded from a servo controller
utilizing a feedback device to close the loop
It consists of three parts:
Controlled device
Output sensor
Feedback system
It is a closed-loop system where it uses a positive feedback system to control
motion and the final position of the shaft. Here the device is controlled by a
feedback signal generated by comparing output signal and reference input signal.
Here reference input signal is compared to the reference output signal and the third
signal is produced by the feedback system. And this third signal acts as an input
signal to the control the device. This signal is present as long as the feedback
signal is generated or there is a difference between the reference input signal and
reference output signal. So the main task of servomechanism is to maintain the
output of a system at the desired value at presence of noises
Servo motors have three wires: power, ground, and signal. The power wire is
typically red, and should be connected to positive pole (+) of your power source.
The ground wire is typically black or brown and should be connected to the
negative pole (-) of your power source.
Program:
#include <Servo.h>
Servo servo;
int angle = 10;
void setup()
servo.attach(8);
servo.write(angle);
Serial.begin(9600);
void loop()
{
// scan from 0 to 180 degrees
for(angle = 10; angle < 150; angle++)
servo.write(angle);
delay(10);
Serial.println(angle);
// now scan back from 180 to 0 degrees
for(angle = 150; angle > 10; angle--)
servo.write(angle);
delay(10);
Serial.println(angle);
}
}
Procedure:
1) Connect the power supply port to Arduino IOT kit
2) Connect the Arduino board through USB connection with CPU
3) Connect the Servomotor pin output to pin D2 in Arduino
4) Compile and upload the sketch with the help of Arduino software
5) Verify the output in serial monitor.
Result: The interfacing of Arduino with Servomotor was implemented and
verified through servomotor interfacing kit.