start:arduino:manette_ps2
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
start:arduino:manette_ps2 [2022/05/09 16:52] – [Détails de connexion :] gerardadmin | start:arduino:manette_ps2 [2023/01/27 16:08] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 41: | Ligne 41: | ||
<code c PS2_Arduino.ino> | <code c PS2_Arduino.ino> | ||
#include < | #include < | ||
- | #include < | ||
PS2X ps2x; /* create PS2 Controller Class*/ | PS2X ps2x; /* create PS2 Controller Class*/ | ||
byte Type = 0; | byte Type = 0; | ||
byte vibrate = 0; | byte vibrate = 0; | ||
- | int RX=0,RY=0,LX=0,LY=0; | + | int rx=0,ry=0,lx=0,ly=0; |
- | LiquidCrystal lcd(2,3,7, 6, 5, 4); /* initialize the library with the numbers of the interface pins*/ | + | |
void setup(){ | void setup(){ | ||
- | lcd.begin(16, 2); /* 16X2 lcd display */ | + | Serial.begin(9600); |
| | ||
Type = ps2x.readType(); | Type = ps2x.readType(); | ||
| | ||
- | lcd.setCursor(0, | + | |
- | | + | |
- | | + | |
- | | + | |
delay(1000); | delay(1000); | ||
- | lcd.clear(); | + | |
} | } | ||
} | } | ||
Ligne 63: | Ligne 62: | ||
| | ||
- | lcd.setCursor(0, | + | |
- | lcd.print(" | + | Serial.println(" |
- | lcd.setCursor(0, | + | |
- | LY = ps2x.Analog(PSS_LY); | + | ly = ps2x.Analog(PSS_LY); |
- | LX = ps2x.Analog(PSS_LX); | + | lx = ps2x.Analog(PSS_LX); |
- | RY = ps2x.Analog(PSS_RY); | + | ry = ps2x.Analog(PSS_RY); |
- | RX = ps2x.Analog(PSS_RX); | + | rx = ps2x.Analog(PSS_RX); |
- | if((LY <= 9)) /* standardize to 3 digit by checking less than 10 */ | + | |
- | | + | if((ly <= 9)) /* standardize to 3 digit by checking less than 10 */ |
- | if((LY >= 9 &&LY <= 99)) /* standardize to 3 digit by checking between 10-99 */ | + | |
- | | + | if((ly >= 9 &&ly <= 99)) /* standardize to 3 digit by checking between 10-99 */ |
- | lcd.print(LY, | + | |
- | lcd.print("," | + | Serial.println(ly, |
- | if((LX <= 9)) /* standardize to 3 digit by checking less than 10 */ | + | Serial.print("," |
- | | + | if((lx <= 9)) /* standardize to 3 digit by checking less than 10 */ |
- | if((LX >= 9 && | + | |
- | | + | if((lx >= 9 && |
- | lcd.print(LX, | + | |
- | lcd.print("," | + | Serial.println(lx, |
- | if((RY <= 9)) /* standardize to 3 digit by checking less than 10 */ | + | Serial.print("," |
- | | + | if((ry <= 9)) /* standardize to 3 digit by checking less than 10 */ |
- | if((RY >= 9 &&RY< | + | |
- | | + | if((ry >= 9 &&rx< |
- | lcd.print(RY, | + | |
- | lcd.print("," | + | Serial.println(ry, |
- | if((RX <= 9)) /* standardize to 3 digit by checking less than 10 */ | + | Serial.println("," |
- | | + | if((rx <= 9)) /* standardize to 3 digit by checking less than 10 */ |
- | if((RX >= 9 &&RX <= 99)) /* standardize to 3 digit by checking between 10-99 */ | + | |
- | | + | if((rx >= 9 &&rx <= 99)) /* standardize to 3 digit by checking between 10-99 */ |
- | lcd.print(RX, | + | |
- | lcd.print(" "); | + | Serial.println(rx, |
+ | Serial.println(" "); | ||
| | ||
- | | + | |
if(ps2x.Button(PSB_START)) | if(ps2x.Button(PSB_START)) | ||
- | lcd.print(" | + | Serial.println(" |
if(ps2x.Button(PSB_SELECT)) | if(ps2x.Button(PSB_SELECT)) | ||
- | lcd.print(" | + | Serial.println(" |
if(ps2x.Button(PSB_PAD_UP)) | if(ps2x.Button(PSB_PAD_UP)) | ||
- | lcd.print("UP PRESSED | + | Serial.println("UP PRESSED |
if(ps2x.Button(PSB_PAD_RIGHT)) | if(ps2x.Button(PSB_PAD_RIGHT)) | ||
- | lcd.print(" | + | Serial.println(" |
if(ps2x.Button(PSB_PAD_LEFT)) | if(ps2x.Button(PSB_PAD_LEFT)) | ||
- | lcd.print("LEFT PRESSED | + | Serial.println("LEFT PRESSED |
if(ps2x.Button(PSB_PAD_DOWN)) | if(ps2x.Button(PSB_PAD_DOWN)) | ||
- | lcd.print("DOWN PRESSED | + | Serial.println("DOWN PRESSED |
if(ps2x.Button(PSB_L1)) | if(ps2x.Button(PSB_L1)) | ||
- | lcd.print("L1 pressed | + | Serial.println("L1 pressed |
if(ps2x.Button(PSB_R1)) | if(ps2x.Button(PSB_R1)) | ||
- | lcd.print("R1 pressed | + | Serial.println("R1 pressed |
if(ps2x.Button(PSB_L2)) | if(ps2x.Button(PSB_L2)) | ||
- | lcd.print("L2 pressed | + | Serial.println("L2 pressed |
if(ps2x.Button(PSB_R2)) | if(ps2x.Button(PSB_R2)) | ||
- | lcd.print("R2 pressed | + | Serial.println("R2 pressed |
if(ps2x.Button(PSB_L3)) | if(ps2x.Button(PSB_L3)) | ||
- | lcd.print("L3 pressed | + | Serial.println("L3 pressed |
if(ps2x.Button(PSB_R3)) | if(ps2x.Button(PSB_R3)) | ||
- | lcd.print("R3 pressed | + | Serial.println("R3 pressed |
if(ps2x.Button(PSB_GREEN)) | if(ps2x.Button(PSB_GREEN)) | ||
- | lcd.print(" | + | Serial.println(" |
if(ps2x.Button(PSB_BLUE)) | if(ps2x.Button(PSB_BLUE)) | ||
- | lcd.print("X pressed | + | Serial.println("X pressed |
| | ||
- | lcd.print(" | + | Serial.println(" |
if(ps2x.Button(PSB_PINK)) | if(ps2x.Button(PSB_PINK)) | ||
- | lcd.print(" | + | Serial.println(" |
delay(700); | delay(700); | ||
} | } | ||
Ligne 134: | Ligne 134: | ||
</ | </ | ||
+ | |||
+ | |||
+ | ===== Liens Manette PS2 <--> Arduino | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | |||
+ | ===== PS2 - Touches ===== | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
+ | Les fonctions les plus pratiques de cette librairie sont : | ||
+ | |||
+ | ***ps2x.config_gamepad(clock, | ||
+ | La fonction définit la broche du contrôleur et la sensibilité à la pression et aux vibrations des moteurs. Si vous voulez que les touches soient insensibles à la pression ou que les moteurs n' | ||
+ | |||
+ | ***ready(); | ||
+ | La fonction détermine le type de contrôleur détecté. 0 signifie que le contrôleur n'est pas détecté correctement, | ||
+ | |||
+ | ***read_gamepad(boolean motor1, byte motor2); | ||
+ | La fonction commencer à lire l' | ||
+ | |||
+ | ***Button (but type); | ||
+ | la fonction renvoie 1 lorsque la touche spécifique de l' | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
+ | |||
+ | ===== Robot Arduino avec manette PS2 (Joystick PlayStation 2) ===== | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
+ | ===== Radiocommande PS2 arduino nrf24l01 ===== | ||
+ | |||
+ | [[https:// |
/home/chanteri/www/fablab37110/data/attic/start/arduino/manette_ps2.1652107924.txt.gz · Dernière modification : 2023/01/27 16:08 (modification externe)