Can't connect my ps2 controller to arduino


Greetings, i am using this code and i am having a trouble in connecting my ps2 controller to arduino, RX and MODE led are blinking in the controller and power led is on in the reciver i've tryed diffrent arduino board, diffrent pins and wires but still having this problem any help ?
#include <PS2X_lib.h>  //for v1.6
#define PS2_DAT        2  //14    
#define PS2_CMD        3  //15
#define PS2_SEL        4  //16
#define PS2_CLK        5  //17
#define pressures   false
#define rumble      false

PS2X ps2x; // create PS2 Controller Class


int error = 0;
byte type = 0;
byte vibrate = 0;

int in1=4;
int in2=5;

int in3=2;
int in4=3;

void avancer();
void gauche();
void droite();
void reculer();
void arreter();
void manette();

void setup() {
 Serial.begin(57600);
  
  delay(300);  
  
  error = ps2x.config_gamepad(PS2_CLK, PS2_CMD, PS2_SEL, PS2_DAT, pressures, rumble);
  
  if(error == 0){
    Serial.print("Found Controller, configured successful ");
  }  
  else if(error == 1)
    Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit 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 www.billporter.info for troubleshooting tips");

  else if(error == 3)
    Serial.println("Controller refusing to enter Pressures mode, may not support it. ");


pinMode(in1,OUTPUT);
pinMode(in2,OUTPUT);
pinMode(in3,OUTPUT);
pinMode(in4,OUTPUT);

}
void loop() { 
manette();
avancer();
}

void reculer() {
   digitalWrite(in1,0);
   digitalWrite(in2,0);
   digitalWrite(in3,0);
   digitalWrite(in4,0);

       
      
     
}

void avancer() {

   
      digitalWrite(in1,1);
       digitalWrite(in2,1);
         digitalWrite(in3,1);
          digitalWrite(in4,1);

    
    
 
}

 void droite(){
   digitalWrite(in1,1);
    digitalWrite(in2,1);
         digitalWrite(in3,0);
          digitalWrite(in4,0);

 
  }
void gauche() {

       digitalWrite(in1,0);
        digitalWrite(in2,0);
        digitalWrite(in3,1);
         digitalWrite(in4,1);

  
         

 
     
}






void arreter()
{
digitalWrite(in1,1);
        digitalWrite(in2,0);
         digitalWrite(in3,1);
          digitalWrite(in4,0);
}
void manette(){

   ps2x.read_gamepad(false, vibrate); //read controller and set large motor to spin at 'vibrate' speed
    
      

     if(ps2x.Button(PSB_PAD_UP))
     {      //will be TRUE as long as button is pressed
      Serial.print("avancer \n");
      avancer();
      //Serial.println(ps2x.Analog(PSAB_PAD_UP), DEC);
    }
    else if(ps2x.Button(PSB_PAD_RIGHT)){
      Serial.print("droite \n");
      droite();
      //Serial.println(ps2x.Analog(PSAB_PAD_RIGHT), DEC);
    }

    else if(ps2x.Button(PSB_PAD_LEFT)){
      Serial.print("Gauche \n");
      gauche();
      //Serial.println(ps2x.Analog(PSAB_PAD_LEFT), DEC);
    }
 
 
    else if(ps2x.Button(PSB_PAD_DOWN)){
      Serial.print("Reculer \n");
      reculer();
     // Serial.println(ps2x.Analog(PSAB_PAD_DOWN), DEC);
    } 
    
    else {
      arreter();
       Serial.print("arreter \n");
      
    }        //will be TRUE as long as button is pressed
      
    
    if(ps2x.ButtonPressed(GREEN_FRET)){
      Serial.println("Green Fret Pressed");
       gauche();}
    if(ps2x.ButtonPressed(RED_FRET)){
      Serial.println("Red Fret Pressed");
      droite();}
    if(ps2x.ButtonPressed(YELLOW_FRET)){
      Serial.println("Yellow Fret Pressed");
      avancer();}
    if(ps2x.ButtonPressed(BLUE_FRET)){
      Serial.println("Blue Fret Pressed");
      reculer();}
    if(ps2x.ButtonPressed(ORANGE_FRET)){
      Serial.println("Orange Fret Pressed");
       gauche();}
    
  
  delay(50);  
  }

You should post code by using code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps
1) press Ctrl-T for autoformatting your code
2) do a rightclick with the mouse and choose "copy for forum"
3) paste clipboard into write-window of a posting

is it a cable-based PS2-controller or a wireless one?
Did you test your PS2-controller with a demo-code that is well known for working?

What messages does the serial monitor show?

Can you please provide a link to the datasheet of your PS2-controller or at least a link where you bought the PS2-controller?

provide a link to the manual or tutorial that you used to connect the things together.

best regards Stefan

It is a wireless controller

Yes i did and still getting the same error

No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips

I just bought it from a local store..

you posted a single picture but not the website where you have the picture from.
The code to use is strong related to the wiring which means the code must match 100% with the wiring.

Are you sure the PS2-controller works on 3.3V?

Attention ! be careful

if the controller is for 3.3V the PS2-controller might get damaged when connecting to 5V

You have to clarify that. If you want support doing this you have to - guess what?

Provide the link to the complete project-description you used.

The microcontroller-world is not superstandardised like USB-devices!
You have to take care of a lot more things than just "does the plug fit into the socket?"

best regards Stefan

Thank you stefan
problem solved, it was just from the library i used an updated one v1.8

This IO-pin-definition does not match your wiring.
Please take a new picture from vertical above so it will be

really easy

to distinguish which wire is plugged into which IO-Pin-socket
best regards Stefan