Introduction: Getting Started With Arduino - Servo Motor

In this tutorial we are going to learn how to control a servo motor. This is a really useful device that allows us to move lots of different things in the real world using an Arduino.

We are going to build a simple example project that uses a dial potentiometer (a turning knob) to control the position of a servo motor.

Step 1: Wire Up Your Arduino

The first job is to connect three wires to your arduino:

  • A blue wire into analog pin A0
  • A black wire into one of the GND (ground) pins
  • A red wire into the 5v pin

Step 2: Connect Your Potentiometer

Next we connect the wires to a dial potentiometer (here we use a 10k potentiometer, but most other types will also work). Connect the black wire to the first pin, the blue to the second and the red to the third (as show in the photo).

Step 3: Connect Your Servo Motor

The next job is to connect your servo motor. There are two common types of servo:

  • White/Red/Black wired servo
  • Orange/Red/Brown wired servo

If your servo has White/Red/Black wires, then connect it as follows (see photo above):

  • White wire connects to digital pin 11 on the arduino
  • Black wire connects to potentiometer GND pin
  • Red wire connects to potentiometer 5v pin

If your servo has Orange/Red/Brown wires, then connect it as follows:

  • Orange wire connects to digital pin 11 on the arduino
  • Brown wire connects to potentiometer GND pin
  • Red wire connects to potentiometer 5v pin

Step 4: Write Your Code

The next step is to write some code to control the servo motor.

Download the ServoPot.ino file and open it up in the Arduino application.

You can tinker with it if you like, or just use it as it is.

Step 5: Enjoy

If everything worked, you should be able to upload your code onto the arduino and control the position of the servo motor using the potentiometer.

If you enjoyed this instructable, check out our other tutorials

If you love this kind of stuff, check out our degree

Comments

author
sunlitho made it! (author)2016-10-22

Didn't work. Just an error.

author

probably something was wrong

author
paulsantony6 made it! (author)2017-04-16

can i use 1k pot

author

sure, should work fine

author
Lawrence.schmitz made it! (author)2016-10-13

Great, simple to follow instructible, thank you.

author
FrankG53 made it! (author)2016-05-17

Thanks! Just learning!

DSC_0563.JPG
author
koubis made it! (author)2016-01-23

clear, easy, good for learning.. thanks!

2016-01-23 21.58.17.jpg
author
Leoncio Soler made it! (author)2015-09-29

Everything worked just fine. Didn't know there was a servo library.

author
Belfastman1958 made it! (author)2015-07-18

When I downloaded the sketch code it wouldn't compile, saying that there was a semicolon - " ; " - missing in line 11.

I typed this in and the sketch compiled ok.

author

Thanks for reporting the problem - have replaced the file with a fixed version

author
PingC1 made it! (author)2015-07-18

https://www.youtube.com/watch?v=6VHdXKLiXk8..

author
fzumrk made it! (author)2015-07-17

I think you meant to say "servo" and not "LEDs" in step 4.

author

oops - yes, you are right. have fixed it

thanks !

author
ibenkos made it! (author)2015-07-16

How do I connect a rf receiver to the arduino to control it? If its posible.

15, 12:07 AM.jpg
author
braytonlarson made it! (author)braytonlarson2015-07-16

There are plenty of tutorials out there showing how to use RF with arduino. The one shown in the photo is a pretty popular transmitter/receiver pair. You might look into a transceiver like the NRFl+ (something like that) which can send and receive signals (hence "transciever"). HopeRF also makes a pretty nice line of transcievers, however they are more expensive at about $5 each. Hope that helped! Remember it's the Internet so if you have a question like this just Google it!

author
Gelfling6 made it! (author)2015-07-16

One side note.. Despite what the example included with the Arduino IDE says, you can actually control more than 8 servos.. Digital outputs 2 through 13, and assigning Outputs 19 through 23 (Analogue pins 0 to 5 can be reassigned as Digital outputs through these numbers) are ALL capable of servo.Write(). BUT!!!!!!!... Recommend using an external power source for them. (Never drive more than 3 servos off the on-board +5V regulator, or it will 'brown-out' (overload, and shut-down), causing the ATMega to reset).. I always use a 7805 regulator external from the Arduino, but can still be in parallel with the voltage going into the vIN plug. (but, not drawn from the vIN pin! I already had to re-bridge the trace on a Duemilinova that got shorted by accident, and burned the trace.)

author
Gelfling6 made it! (author)Gelfling62015-07-16

minor correction, 19 through 24.. (Sorry, skipped the A5)

About This Instructable

16,066views

317favorites

License:

Bio: Tutorials provided by BA/BSc (Hons) Digital Art and Technology at Plymouth University
More by Digital Art and Technology:Green space activity monitorPython Micro:bit Light ShowJumpstarting a Hot-glued Arduino
Add instructable to: