SERVO MOTOR WITH ARDUINO UNO R3

About: PrimeRobotics is a E-Commerce site, which focus on supplying right products to Electronics Hobbyists, Enthusiast & Students.

Servo is a type of geared motor that can only rotate 180 degrees. It is controlled by sending electrical pulses from your Arduino Uno board. These pulses tell the servo what position it should move to.

Step 1: Components Required

Step 2: Principle

Servo consists of shell, circuit board, non-core motor, gear and location detection. Its working principle is as follows: Arduino Uno board sends PWM signal to servo motor, and then this signal is processed by IC on circuit board to calculate rotation direction to drive the motor, and then this driving power is transferred to swing arm by reduction gear. At the same time, position detector returns location signal to judge whether set location is reached or not.

Step 3: Schematic Diagram

Step 4: Procedures

Step1:

Build the circuit.

Step 2:

Download the code from https://github.com/primerobotics/Arduino

Step 3:

Upload the sketch to the Arduino Uno board

Click the Upload icon to upload the code to the control board.

If "Done uploading" appears at
the bottom of the window, it means the sketch has been successfully uploaded.

Now, you can see the servo motor rotate 90 degrees (rotate once every 15 degrees). And then rotate in the opposite direction.

Step 5: Code

/***********************************************

* name:Servo

* function:you can see the servo motor rotate 90 degrees (rotate once every 15 degrees).

* And then rotate in the opposite direction.

************************************************/

//Email: info@primerobotics.in

//Website: www.primerobotics.in

#include

/************************************************/

Servo myservo;//create servo object to control a servo

/************************************************/

void setup()

{

myservo.attach(9);//attachs the servo on pin 9 to servo object

myservo.write(0);//back to 0 degrees

delay(1000);//wait for a second

}

/*************************************************/

void loop()

{

myservo.write(15);//goes to 15 degrees

delay(1000);//wait for a second

myservo.write(30);//goes to 30 degrees

delay(1000);//wait for a second.33

myservo.write(45);//goes to 45 degrees

delay(1000);//wait for a second.33

myservo.write(60);//goes to 60 degrees

delay(1000);//wait for a second.33

myservo.write(75);//goes to 75 degrees

delay(1000);//wait for a second.33

myservo.write(90);//goes to 90 degrees

delay(1000);//wait for a second

myservo.write(75);//back to 75 degrees

delay(1000);//wait for a second.33

myservo.write(60);//back to 60 degrees

delay(1000);//wait for a second.33

myservo.write(45);//back to 45 degrees

delay(1000);//wait for a second.33

myservo.write(30);//back to 30 degrees

delay(1000);//wait for a second.33

myservo.write(15);//back to 15 degrees

delay(1000);//wait for a second

myservo.write(0);//back to 0 degrees

delay(1000);//wait for a second

}

/**************************************************/

Share

    Recommendations

    • Faux-Real Contest

      Faux-Real Contest
    • Paper Contest

      Paper Contest
    • Build a Tool Contest

      Build a Tool Contest

    Discussions