Introduction: Very Basic Pan Tilt Using Arduino

Picture of Very Basic Pan Tilt Using Arduino
for this instructable you will be learning the basics of arduino and codes for arduino.

video of pan/tilt arduino project (careful, this video contains aweful impressions of batman)

if anybody wants me to put up more photos on this project please message me.

Step 1: Supplies and Wiring

Picture of Supplies and Wiring

things you will need:

-2 sub-micro servo motors

-one pan/tilt bracket

-various jumper wires

-mini breadboard



-(optional) batman's head, two LEDs, and a tiny hat

Step 2: Description of Wiring

Picture of Description of Wiring

i don't have any photos for this process but i will make some if i am asked enough.

wire the data wire of the bottom servo to pinhole ~9 and wire the data wire of the top servo to pinhole ~10, the data wire is usually the white or yellow wire of the servo.

the y axis pin of the joystick goes to A0, x axis pin goes to A1

for powering everything connect allpositives to the 5V pinhole on the arduino and allnegatives to the GND pinhole on the arduino, i used a mini breadboard for this

Step 3: CODE

Picture of CODE

below is code for the arduino, i suggest using this stuff if you want your cool new pan/tilt machine to work!


// Controlling two servos positions using two potentiometers or a joystick
// modified knob example by kevin jones original code by Michal Rinott


Servo myservo0;  // create servo object to control a servo
Servo myservo1;

int potpin0 = 0;  // analog pin used to connect the potentiometer
int potpin1 = 1;
int val;    // variable to read the value from the analog pin

void setup()
  myservo0.attach(9);   // attaches servo to pin 9
  myservo1.attach(10);  // attaches the servo on pin 10 to the servo object

void loop()
  val = analogRead(potpin0);            // 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)
  myservo0.write(val);                  // sets the servo position according to the scaled value
  delay(25);                           // waits for the servo to get there
  val = analogRead(potpin1);            // bananas are high in potassium
  val = map(val, 0, 1023, 0, 179);     //
  myservo1.write(val);                  //
  delay(25);                           //


gergerdgp (author)2016-12-25

pan tilt motor dc with joystic forward n reverse and potensiometer for speed contro. please share code

alumpkins (author)2015-12-05

The code is not working

Robertlb56 (author)alumpkins2016-03-22

It is missing the library reference. Try changing the first line of code to:

#include <Servo.h>

katman101 (author)alumpkins2015-12-11

it could be outdated, this is an old instructable.

About This Instructable




Bio: i like fish and technology.
More by katman101:very basic pan tilt using arduino
Add instructable to: