Introduction: Very Basic Pan Tilt Using 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
Step 2: 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
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
int potpin0 = 0; // analog pin used to connect the potentiometer
int potpin1 = 1;
int val; // variable to read the value from the analog pin
myservo0.attach(9); // attaches servo to pin 9
myservo1.attach(10); // attaches the servo on pin 10 to the servo object
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); //