Electronics Forums

Electronics Forums > Electronics Forums > Project Logs > Arduino Pan and Tilt

Reply
Thread Tools Display Modes

Arduino Pan and Tilt

 
 
Junior Member
Join Date: Apr 2012
Posts: 8
 
      04-15-2012, 11:33 PM
Hello, I am working on an arduino controlled pan and tilt mechanism.
http://youtu.be/BgpscJsXOcs

I used two parallax hobby servos available at Radio Shack. I could have ordered some specialty brackets online, but I have little patience.
I soldered some header pins onto a perf board for connecting the servo plugs to a prototyping board.

Control is allowed with 2 100K ohm potentiometers .. I think ultimately I will connect it to an analog thumbstick that has been collecting dust for a while.

The code is based on the Arduino Knob example program.
// Code to allow the arduino to control 2 servos independently ..
#include <Servo.h>
Servo myservo; // create servo object to control a servo
Servo myservo1;
int potpin = 0; // analog pin used to connect the potentiometer
int potpin1 = 1;
int val; // variables to read the value from the analog pins
int valu;
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 and 10 to the servo object
myservo1.attach(10);
}
void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer
valu = analogRead(potpin1);
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo s
valu = map(valu, 0, 1023, 0, 179);
myservo.write(val); // sets the servo position according to the scaled value
myservo1.write(valu);
delay(15); // waits for the servo to get there
}
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mcam100 pan & tilt home security camera Will Hoevenaars Hobby Electronics 5 07-06-2008 10:50 AM
Pan/tilt controller with center on click Andrew Electronic Design 5 01-09-2007 01:32 PM
Pan & tilt webcam - USB or Parallel port interfacing? Clayton Electronic Design 11 11-27-2006 10:24 AM
Camera Pan/Tilt controller cjlectronics@yahoo.com Electronic Design 4 10-05-2005 01:24 AM
FA: pulnix beams and pan & tilt zoom Security Alarms 0 02-17-2004 06:43 PM