Arduino webcam pan tilt control with the KY-023

Hello world! Today i made a Arduino webcam pan tilt control with a old webcam, Dont mind the bad video, i said “OLD” LoL! Its pretty easy to build you need 2 servos a joystick, the schematic, code, and a little creativity. Follow the link for the Schematic Code & Parts List. I simply taped the Servos on top of each other, because i always take my projects apart after my instructables and videos are done.

Schematic:
Arduino webcam pan tilt control

Just wire it up like the schematic & it should work after uploading the code.
Make sure you have the servo.h library installed.

Parts list:
Arduino Uno, I used the robotdyn UNO.
KY-023 JoyStick Module.
2 X Servo motor.
Jumper wires set. MM/FF/MF
Old Webcam or any other camera that you wanna use. Small is better.
Some creativity to mount the servos.

Code:

/*
Author: Danny van den Brande, Arduinosensors.nl. BlueCore Tech.
Hello world! This code is made for pan tilt control with a USB Webcam using servos and a PS2 Joystick..
 */

#include <Servo.h>
Servo CAMservo1;  
Servo CAMservo2; 

const int servo1 = 5;       
const int servo2 = 6;       
const int Jstick1 = 0;        // Left right
const int Jstick2 = 1;        // Up down

int ServValue;          
 
void setup() {
  Serial.begin(9600);
  CAMservo1.attach(servo1);  
  CAMservo2.attach(servo2);  
}


void loop(){
    PrintValue();
    ServValue = analogRead(Jstick1);          
    ServValue = map(ServValue, 0, 1023, 0, 180);     
    CAMservo2.write(ServValue);                         
    ServValue = analogRead(Jstick2);           
    ServValue = map(ServValue, 0, 1023, 70, 180);     
    CAMservo1.write(ServValue);                           
    delay(15);                                  

}

void PrintValue(){

    Serial.print(analogRead(Jstick1));
    Serial.print (" - "); 
    Serial.print(analogRead(Jstick2));
    Serial.println (" Joystick Value");
}
Danny van den Brande

http://www.arduinosensors.nl

Programmer, Game Designer, 3D Designer, Web Designer, Graphic Designer. Jup this website looks crappy.. :) But enjoy the projects! Everything you need is here.

Leave a Reply

Your email address will not be published. Required fields are marked *