Getting started with Arduino – Servo motor

Written by: techguru

Picture of Getting started with Arduino - Servo motorpotentiometer.jpg

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

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

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

Picture of 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.

http://www.instructables.com/files/orig/FJK/057E/ICACHJ80/FJK057EICACHJ80.ino

Step 5: Enjoy

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

Leave a Reply