This instructable shows how to control the angle of a servo motor using a potentiometer.

Part List:

1) Arduino ( any kind will do)

2) Bread board

3) Male to Male jumper wires

4) Servo motor

5) Potentiometer ( 10k should work fine)

Step 1: Connecting the Potentiometer:

1) Connect the potentiometer to any three open rows on the breadboard.

2) Connect negative pin of the potentiometer to ground rail on the breadboard.

3) Connect positive pin of the potentiometer to power rail on breadboard.

4) Connect signal pin of the potentiometer to PIN0 on the Arduino.

Step 2: Connecting the Servo:

1) Insert three Male to Male Jumpers into the servo's Female hub.

2) Connect the positive wire (usually red) of the Servo motor to power rail on the breadboard.

3) Connect the negative wire (usually black or brown) of the servo motor to the ground rail on the breadboard.

4) Connect the Signal wire (usually yellow, white or orange) of the Servo motor to PIN2 on the Arduino.

Step 3: Connecting the Arduino:

1) Connect the 5vPIN of the arduino to the power rail on the breadboard.

2) Connect the GNDPIN of the arduino to the ground rail on the breadboard.



// Controlling a servo position using a potentiometer (variable resistor)


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, 179); // 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


<p>hey &gt;&gt;</p><p>can u help me ?? <br>i made this project but the servo motor does not stopped when the potentiometer stopped ?? </p><p>u can watch the video :) &gt;&gt; </p><p><iframe allowfullscreen="" frameborder="0" height="281" src="//www.youtube.com/embed/MqKGfDa8M2Y" width="500"></iframe></p>
<p>Hellow, the small servo motor which you have happens to be a continuous rotating servo. Did you mod the servo yourself? And yea, the motor looses it's ability to feedback it's position to the arduino which results in you not having control over the motor.</p>
<p>Hellow Friends :D Could you please spare some time and checkout my new instructable ? <a href="https://www.instructables.com/id/Simple-LM386-Powered-Audio-Amplifier-Breadboard-Ve/" rel="nofollow">https://www.instructables.com/id/Simple-LM386-Powe...</a></p><p>Thanks a lot for all your support and appreciations. :D </p>
<p>I made it but i can't upload pictures. i had to take the delay in the code out before the servo would work with the potentiometer. </p>
<p>I think i made the images larger.. Thank you people, hope it was instructable.</p>
<p>This looks like an easy way to start with servos on an Arduino. The pictures may be a little small, but I like your effort.</p><p>Thanks.</p>
<p>Your pictures are too small . Cant get them big enough</p>
<p>Wrong comment on line which attach the servo to the pin 2 of the arduino.</p><p>Don't want to be a troublemaker, but it can be puzzling for a person who is not aware of arduino programming.</p>
<p>Can you make your pictures larger?</p>

About This Instructable




More by Surya Krishnakumar:Arduino HCSR04 leds distance warner Arduino DC Motor Speed Control Potentiometer Arduio Dc motor speed control serial monitor ..(no l293d) 
Add instructable to: