Servo Motor + Potentiometer + Arduino: Potentiometer-Controlled Servo




About: I love to make projects based on microcontrollers including robots and IoT technologies. Absolutely, truly, madly, deeply in love with planes. I also dabble in the art of Origami and play chess in my spare ...

Hello World!

I'm Unicorn Clockworks, here with another project. Today, we will be controlling a servo motor's angle using a potentiometer knob, where the angle of the servo motor corresponds to the rotational displacement of the potentiometer with a linear correlation.

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: Materials

  • Arduino or Arduino-compatible microcontroller
  • Servo Motor
  • Potentiometer
  • Jumper Wires
  • [Optional] Breadboard

Step 2: Potentiometer Connections

  • Connect the Grey wire from the VCC pin of the potentiometer (pin 1) to the 3.3V pin on the Arduino.
  • Connect the Green wire from the signal wire of the potentiometer (pin 2) to pin A0 on the Arduino.
  • Connect the Purple wire from the ground wire of the potentiometer (pin 3) to the GND pin on the Arduino

Step 3: Servo Connections

  • Connect the Blue wire from the signal pin of the servo motor (orange-coloured wire) to pin 3 on the Arduino
  • Connect the Red wire from the VCC pin of the servo motor (red-coloured wire) to the 5V pin on the Arduino
  • Connect the Black wire from the ground pin of the servo motor (black-coloured wire) to the GND pin on the Arduino

Step 4: Code

//include the servo library
#include <Servo.h>
//create a servo object 
Servo servo1;  
// declare the pins to which the servo and potentiometer is connected. 
const int servoPin = 3;
const int pot = 0;
int potValue;
void setup() {
  //associate servo1 to pin 9 on the Arduino 101
void loop() {
  // put your main code here, to run repeatedly:
    potValue = analogRead (pot);
    // linearly scale the value of the sevo output from the 0 to 1023 range of the potentiometer
    // to the angle limits by the servo which is 0 to 180 degrees
    potValue = map(potValue, 0, 1023, 0, 180);
    // record the now-adjusted value of the potentiometer to the servo motor

Step 5: It Works!

Turn the knob of the potentiometer and watch the servo motor move along with it.

Enjoy your build and have fun!

Unicorn ClockWorks Out!

Makerspace Contest 2017

Participated in the
Makerspace Contest 2017

1 Person Made This Project!


  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest



1 year ago

I shared this with my class as they built the same project. Thanks for the help