Sweeping Servo

by JeanC117 in Circuits > Arduino

3640 Views, 8 Favorites, 0 Comments

Sweeping Servo

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
  • Arduino Uno
  • Servo Motor
  • 3 pieces of Jumper Cables

Attaching the Servo to Arduino

2016-07-21 15.29.50.jpg
Screen Shot 2017-07-28 at 1.42.42 AM.png
  1. Connect the black female pin of the servo motor to the GND pin in the Arduino.
  2. Connect the red female pin of the servo motor to the 5V pin in the Arduino.
  3. 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

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
//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

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.