How to Control a Servo With Arduino

About: I like to create new things! I'm very interested in IOT and just Internet Stuff. I am not responsible for any injury or deaths caused by my projects.

Lets control a Servo Motor with Arduino! All the parts you will need i got in a handy little kit from GearBest, if you want you can check it out here!

The parts you will need are:

1) Arduino Board

2) Servo

3) Potentiometer

4) Wires

Let's Get Started!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Piece Everything Togeather

I created the schematic in the picture, to make it easier to put together, then connected all the wires

Step 2: Program It

I used the example code with the Arduino IDE but if you don't have it's below!


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

int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object

void loop() {
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there

Step 3: Test It Out

It should now work, plug it in and move the POT around the servo should move with it YAAY! Hope you liked it!

If you have any questions just leave them in the comments and I will try to answer them!

Watch The Video

Maker Olympics Contest 2016

Participated in the
Maker Olympics Contest 2016

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest