Driving Servo Motors with L293D Shield
Definition:
A servo motor is a rotary actuator or a motor that allows for a precise control in terms of the angular position, acceleration, and velocity. Basically it has certain capabilities that a regular motor does not have. Consequently it makes use of a regular motor and pairs it with a sensor for position feedback .
Types of servo motors:
Servo motors can be of different types on the basis of their applications. The most important amongst them are : AC servo motor, DC servo motor, brushless DC servo motor, positional rotation servo motor, continuous rotation servo motor, and linear servo motor.
A typical servo motor comprises of three wires namely- power, control, and ground. The shape and size of these motors depends on their applications.
DC servo motor:
The basic operating principle of DC motor is the same as other electromagnetic motors. The design, construction, and the modes of operation are different. The rotors of this kind of motor are designed with long rotor length and smaller diameters. Their size is larger than that of conventional motors of same power ratings.
The motor shield actually breaks out Arduino’s 16bit PWM output pins #9 & #10 to the edge of the shield with two 3-pin headers. PWM pins, the sketch uses IDE’s built in Servo library.
ARDUINO COE FOR SERVO MOTOR:
#include <Servo.h> Servo myservo; // create servo object to control a servo int pos = 0; // variable to store the servo position void setup() { // attaches the servo on pin 10 to the servo object myservo.attach(10); } void loop() { // sweeps from 0 degrees to 180 degrees for(pos = 0; pos <= 180; pos += 1) { myservo.write(pos); delay(15); } // sweeps from 180 degrees to 0 degrees for(pos = 180; pos>=0; pos-=1) { myservo.write(pos); delay(15); } }