Ps2 controller exploitation des données joysticks

Bonjour

Je te mets un petit exemple avec le bouton Select

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

PS2X ps2x; // create PS2 Controller Class

const byte PS2_DAT          = 14;
const byte PS2_CMD          = 15;
const byte PS2_SEL          = 16;
const byte PS2_CLK          = 17;

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

void setup(){
 Serial.begin(115200);

 //CHANGES for v1.6 HERE!!! **************PAY ATTENTION*************
  
 error = ps2x.config_gamepad(PS2_CLK, PS2_CMD, PS2_SEL, PS2_DAT, 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");
		Serial.println("Try out all the buttons, X will vibrate the controller, faster as you press harder;");
		Serial.println("holding L1 or R1 will print out the analog stick values.");
		Serial.println("Go to www.billporter.info for updates and to report bugs.");
	}
   
	else
		Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips");
}

void loop(){
	ps2x.read_gamepad(false, vibrate);          //read controller
	
    if(ps2x.Button(PSB_SELECT))
    {
	    Serial.println("Select is being held");
	    vibrate = 200;
    }
	else
	{
		vibrate = 0;
	}
	
	delay(50);     
}

En fait il suffit de faire

ps2x.read_gamepad(false, vibrate)

vibrate (byte) de 0 à 255.

Cordialement
jpbbricole