Control servo to rotate 180 degrees

Control servo to rotate 180 degrees

In this section, we will use the new method to control the servo.  We found that if the Arduino provided by the library was used, some of the servo can not accurately rotate the angle we need. Through our study different steering gears were found. Different types of steering gear has different operating frequency. So we provide the following method: adjust corresponding frequency according to different servos.
– 1 * Adeept UNO R3 Board
– 1 * USB Cable
– 1 * Adeept Servo
– Several jumper wires

The servo motor has three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. Usually the signal pin is yellow, orange or white, and should be connected to a digital pin on the Arduino board. Note that the servo motor draws a considerable amount of power, if you need to drive more than one or two servos, you’ll probably need to power them with an extra supply (i.e. not the +5V pin on your Arduino). Be sure to connect the grounds of the Arduino and external power supply together.
1. Build the circuit

2. Program

File name: Adeept_servo_PRO.ino
Description:   The servo motor are rotated  from 
               0 degrees to 180 degrees and from 180 degrees to
               0 degrees.
Author: Tom
Date: 2017/01/07 
int servopin = 9;    //Define servo interface digital interface 7
int angle =0;        //Angle of rotation of the servo

void servopulse(int angle)//Define an impulse function
  int pulsewidth=(angle*11)+500;  //The angle is converted to a pulse width value of 500-2480
  digitalWrite(servopin,HIGH);    //The servo interface level to the highest
  delayMicroseconds(pulsewidth);  //The number of microseconds of the delay pulse width value
  digitalWrite(servopin,LOW);     //The servo interface level to low
  delayMicroseconds(20000-pulsewidth); //20000 can be replaced: "frequency = 1 / (20000/1000000)"

void setup()
  pinMode(servopin,OUTPUT);//Set the servo interface as the output interface

void loop()
      //Reference impulse function
//    for(angle=180;angle>=0;angle--){
//      //Reference impulse function
//      servopulse(angle);
//      delay(20);
//  }

3. Compile the program and upload to Arduino UNO board
Now, you should see the servo rotate from 0 to 180 degrees, and then do it in the opposite direction.

One Reply to “Control servo to rotate 180 degrees”

  1. Here at Leslie’s Pugsland Breeder, Our beautiful fawn pug has given birth to 4 healthy Pug puppies.
    She is our beloved family dog and this is her 1st litter.
    Both mum and dad are AKC registered with 5 gen pedigree certificate. Both from Top Champion bloodlines.Mum and Dad can be seen. Puppies have been wormed weeks 2,4,6,8 and will have had a flea preventative treatment before leaving us.
    They will have their vet check, 1st vaccinations and microchip.
    To view all available puppies and recent pictures, Search us in google as LESLIE’S PUGSLAND BREEDER or click on our website link bellow :

    Pug Puppies for sale | pug for sale near me | pug puppy for sale | pug puppy | pug for sale | pug puppies for sale in va | black pug puppies for sale

Leave a Reply