how to control servo motor(analog or digital servo) with ps2 remote and Arduino Uno r3?

hello, I just want to control my servo Pan tilt with my ps2 remote and arduino uno R3. It means when i press the Triangle(Green) button it will move clock wise, and when i press X(Blue) button it will move counter clock wise. and this condition will true when button will press. unless it stop at current position.

Simple google search will give you all the info you need to connect the controller to the Arduino and have the arduino read what buttons are being pressed. Then it's a simple matter of integrating the servo into the code and your set. The Arduino Forums are full of similar projects.

vrushank26 (author)  mpilchfamily2 years ago
I searced many time on google but I can not find any satisfied result.
I know about how to connect ps2controller with arduino and I also have ps2x library file. But the problem is that I am not a good programmer and I make lost of programmer with the ps2x program but I can not control servo with ps2 remote.
So if you are a good programmer or a devloper, so please give me the better arduino program and any clue to complete this project.

Here is the cody buddy

#include <PS2X_lib.h> //for v1.6

#include <Servo.h>

Servo vertical;

int pos=90;

PS2X ps2x; // create PS2 Controller Class

int error = 0;

byte type = 0;

byte vibrate = 0;

void setup(){




error = ps2x.config_gamepad(9,11,10,12, true, true); //setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error

if(error == 0){

Serial.println("Found Controller, configured successful");


else if(error == 1)

Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit http://www.billporter.info for troubleshooting tips");

else if(error == 2)

Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit http://www.billporter.info for troubleshooting tips");

else if(error == 3)

Serial.println("Controller refusing to enter Pressures mode, may not support it.");


void loop(){

if(error == 1) //skip loop if no controller found





Serial.print("right held");





Serial.print("LEFT held");