642Views3Replies

Author Options:

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

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.

Tags:arduino

3 Replies

user
mpilchfamily (author)2014-12-09

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.

Select as Best AnswerUndo Best Answer

user
vrushank26 (author)mpilchfamily2014-12-09

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.

Select as Best AnswerUndo Best Answer

user

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(){

Serial.begin(57600);

vertical.attach(3);

vertical.write(90);

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

return;

if(ps2x.Button(PSB_PAD_RIGHT)){

pos+=1;

vertical.write(pos);

Serial.print("right held");

}

if(ps2x.Button(PSB_PAD_LEFT)){

pos-=1;

vertical.write(pos);

Serial.print("LEFT held");

}}

Select as Best AnswerUndo Best Answer