loading

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.

Step 4: BREADBOARD LAYOUT:

Step 5: ARDUINO CODE:

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


#include

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
}

Step 6: TEST IT... AND MAKE YOUR OWN PROJECTS WITH THIS CONCEPT.

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

5,316views

25favorites

License:

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: