Sweeping Servo
![2016-07-21 15.34.25.jpg](/proxy/?url=https://content.instructables.com/F71/THEB/J5K5ZBE0/F71THEBJ5K5ZBE0.jpg&filename=2016-07-21 15.34.25.jpg)
Servo motors are small, lightweight, and energy efficient rotary actuators which allows for a precise and accurate rotary control to a certain angular limit, normally 180 degrees. They utilize a closed-loop control system to provide the user feedback and control of the the angle of a servo control horn attached to the top-most gear.
Servos are commonly used in robotics for the precise contort of a bipedal robot and in radio-controlled airplanes to position control surfaces like elevators, rudders. The
This project focuses on the basic use of a servo motor control, specifically the ability to control the angle in which the servo horn moves with precision.
Tools and Materials
![2016-07-21 15.26.47.jpg](/proxy/?url=https://content.instructables.com/FDG/J6KY/J5K5ZBA8/FDGJ6KYJ5K5ZBA8.jpg&filename=2016-07-21 15.26.47.jpg)
- Arduino Uno
- Servo Motor
- 3 pieces of Jumper Cables
Attaching the Servo to Arduino
![2016-07-21 15.29.50.jpg](/proxy/?url=https://content.instructables.com/FOY/G4II/J5K5ZBBI/FOYG4IIJ5K5ZBBI.jpg&filename=2016-07-21 15.29.50.jpg)
![Screen Shot 2017-07-28 at 1.42.42 AM.png](/proxy/?url=https://content.instructables.com/FH4/BYP3/J5MQ9VY9/FH4BYP3J5MQ9VY9.png&filename=Screen Shot 2017-07-28 at 1.42.42 AM.png)
- Connect the black female pin of the servo motor to the GND pin in the Arduino.
- Connect the red female pin of the servo motor to the 5V pin in the Arduino.
- Connect the white female pin of the servo motor to the digital pin 9 in the Arduino.
Securing the Servo
![2016-07-21 15.33.45.jpg](/proxy/?url=https://content.instructables.com/F87/9F62/J5K5ZBCS/F879F62J5K5ZBCS.jpg&filename=2016-07-21 15.33.45.jpg)
4. Using tape, adhere the body of the servo motor to any flat surface to counter the torque produced by the servo motor as it turns it gears.
Coding
![Screen Shot 2017-07-22 at 4.34.14 PM.png](/proxy/?url=https://content.instructables.com/FF0/BK8E/J5CQ8Y32/FF0BK8EJ5CQ8Y32.png&filename=Screen Shot 2017-07-22 at 4.34.14 PM.png)
//include the servo library #include <SoftwareServo.h>
//create a servo object Servo myServo;
// declare the pins to which the servo is connected. const int servoPin = 9;
void setup() { //connect 'myServo' to pin 9 on the Arduino myServo.attach(9); //initialize the position to 0 degrees myServo.write (0); }
void loop() { // move the servo angle to 90 degrees myServo.write(90); delay (500); // move the servo to its maximum angle 180 degrees myServo.write (180); delay (500);
// move the servo angle back to 0 degrees myServo.write (0); delay (500); }
Servo Control Demo
![Sweeping Servo Motor](/proxy/?url=https://content.instructables.com/F0I/ULNE/J5K5YZZQ/F0IULNEJ5K5YZZQ.jpg&filename=Sweeping Servo Motor)
The servo motors, first moves to 90 degrees, then 180 degrees, then back to 0 degrees. This demonstration videos shows the accuracy and precision of the servo motor.