Hjælp til PSX controler på arduino (Læst 5959x)

Offline Julle

  • Jordet Collector
  • *
  • Indlæg: 116
  • Antal brugbare Indlæg: 2
    • Vis profil
Hjælp til PSX controler på arduino
« Dato: Februar 03, 2015, 23:05:05 »
Hej til alle jer kloge hoveder

jeg er ved at lege lidt med en PS1 controller og kan bare ikke få den til at skrive andet ind

 
Citér
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535
65535

jeg har prøvet alt syndes jeg og jeg ved ikke lige hvad jeg skal gøre kan i hjælp mig lidt

link til pin jeg har bruge
http://pinouts.ru/Game/playstation_9_pinout.shtml

link til Lib:
http://playground.arduino.cc/Main/PSXLibrary


Kode:
#include <Psx.h>                                          // Includes the Psx Library 
                                                          // Any pins can be used since it is done in software
#define dataPin 4
#define cmndPin 3
#define attPin 2
#define clockPin 5

#define LEDPin 13

Psx Psx;                                                  // Initializes the library

unsigned int data = 0;                                    // data stores the controller response

void setup()
{
  Psx.setupPins(dataPin, cmndPin, attPin, clockPin, 10);  // Defines what each pin is used
                                                          // (Data Pin #, Cmnd Pin #, Att Pin #, Clk Pin #, Delay)
                                                          // Delay measures how long the clock remains at each state,
                                                          // measured in microseconds.
                                                          // too small delay may not work (under 5)
  pinMode(LEDPin, OUTPUT);                                // Establishes LEDPin as an output so the LED can be seen
  Serial.begin(9600);
}

void loop()
{
  data = Psx.read();                                      // Psx.read() initiates the PSX controller and returns
                                                          // the button data
  Serial.println(data);                                   // Display the returned numeric value
  if (data & psxR2)                                       // If the data anded with a button's hex value is true,
                                                          // it signifies the button is pressed. Hex values for each
                                                          // button can be found in Psx.h
  {
    digitalWrite(LEDPin, HIGH);                           // If button is pressed, turn on the LED
  }
  else
  {
    digitalWrite(LEDPin, LOW);                            // If the button isn't pressed, turn off the LED
  }
  delay(50);
}
håber i kan hjælpe mig lidt
Hilsen Klaus

 

Offline Jesper_Munkholm

  • µProcessoren
  • *
  • Indlæg: 380
  • Antal brugbare Indlæg: 36
  • Alt er Volt
    • Vis profil
Sv: Hjælp til PSX controler på arduino
« Svar #1 Dato: Februar 03, 2015, 23:16:42 »
Jeg kigger gerne gemmerne igennem, hvis du kan vente til næste uge! Jeg købte en ps1 trådløs controller i Kina, fandt noget brugbart kode, tilpassede den til mit projekt og koblede div. Servo til den! Det hele virkede, også vibratoren
"Buy a man a beer and he wastes an hour. Teach a man to brew and he wastes a lifetime." :)

 

Offline Julle

  • Jordet Collector
  • *
  • Indlæg: 116
  • Antal brugbare Indlæg: 2
    • Vis profil
Sv: Hjælp til PSX controler på arduino
« Svar #2 Dato: Februar 04, 2015, 00:05:45 »
det er ikke noget der haster men kan bare ikke forstå hvad det er jeg har gjort fejl ( har ikke prøver en 1k modstand mellem data og 3v3 pin ved ikke om det er der fejlen er ?)
Hilsen Klaus

 

Offline Julle

  • Jordet Collector
  • *
  • Indlæg: 116
  • Antal brugbare Indlæg: 2
    • Vis profil
Sv: Hjælp til PSX controler på arduino
« Svar #3 Dato: Februar 17, 2015, 08:58:38 »
nogle der har lidt tid til at hjælpe ?
Hilsen Klaus

 

Offline asm7100

  • Højpas filter
  • *****
  • Indlæg: 309
  • Antal brugbare Indlæg: 17
  • Hvis det ikke kan gøres så gør det alligevel.
    • Vis profil
Sv: Hjælp til PSX controler på arduino
« Svar #4 Dato: Februar 17, 2015, 12:33:33 »
Har du prøvet at google det.?
http://www.instructables.com/id/PiStation-A-Raspberry-Pi-Emulation-Console/
Her er der noget omkring at bygge en RPI ind i en PS1, måske der er noget at hente.
Prøv at søg på noget alternativt, måske ikke direkte forbindelse med det du laver.
MVH
Allan Madsen

 

Offline Jesper_Munkholm

  • µProcessoren
  • *
  • Indlæg: 380
  • Antal brugbare Indlæg: 36
  • Alt er Volt
    • Vis profil
Sv: Hjælp til PSX controler på arduino
« Svar #5 Dato: Februar 18, 2015, 13:32:01 »
Prøv denne kode: (kun testet med en trådløs ps2 controller fra kina, med det virkede 100%)
Kode:
#include <PS2X_lib.h>  //for v1.6
#include <Servo.h>
PS2X ps2x; // create PS2 Controller Class
Servo myservo;  //V horisontal  create servo object to control a servo
Servo myservox; //V veritkal 
Servo myservoy; //H horisontal
Servo myservoz; //H vertikal

//right now, the library does NOT support hot pluggable controllers, meaning
//you must always either restart your Arduino after you conect the controller,
//or call config_gamepad(pins) again after connecting the controller.
int error = 0;

int val;    // variable to read the value from the analog stick
int valx;
int valy;
int valz;

byte type = 0;
byte vibrate = 0;

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

  myservo.attach(3);  // LY attaches the servo on pin 3 to the servo object
  myservox.attach(9); // LX
  myservoy.attach(5); // RY
  myservoz.attach(6); // RX
 
 //CHANGES for v1.6 HERE!!! **************PAY ATTENTION*************
 
 error = ps2x.config_gamepad(13,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");
   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 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. ");
   
   //Serial.print(ps2x.Analog(1), HEX);
   
   type = ps2x.readType();
     switch(type) {
       case 0:
        Serial.println("Unknown Controller type");
       break;
       case 1:
        Serial.println("DualShock Controller Found");
       break;
       case 2:
         Serial.println("GuitarHero Controller Found");
       break;
     }
 
}

void loop(){
   /* You must Read Gamepad to get new values
   Read GamePad and set vibration values
   ps2x.read_gamepad(small motor on/off, larger motor strenght from 0-255)
   if you don't enable the rumble, use ps2x.read_gamepad(); with no values
   
   you should call this at least once a second
   */
   
   
   
 if(error == 1) //skip loop if no controller found
  return;
 
 if(type == 2){ //Guitar Hero Controller
   
   ps2x.read_gamepad();          //read controller
   
   if(ps2x.ButtonPressed(GREEN_FRET))
     Serial.println("Green Fret Pressed");
   if(ps2x.ButtonPressed(RED_FRET))
     Serial.println("Red Fret Pressed");
   if(ps2x.ButtonPressed(YELLOW_FRET))
     Serial.println("Yellow Fret Pressed");
   if(ps2x.ButtonPressed(BLUE_FRET))
     Serial.println("Blue Fret Pressed");
   if(ps2x.ButtonPressed(ORANGE_FRET))
     Serial.println("Orange Fret Pressed");
     

    if(ps2x.ButtonPressed(STAR_POWER))
     Serial.println("Star Power Command");
   
    if(ps2x.Button(UP_STRUM))          //will be TRUE as long as button is pressed
     Serial.println("Up Strum");
    if(ps2x.Button(DOWN_STRUM))
     Serial.println("DOWN Strum");
 
 
    if(ps2x.Button(PSB_START))                   //will be TRUE as long as button is pressed
         Serial.println("Start is being held");
    if(ps2x.Button(PSB_SELECT))
         Serial.println("Select is being held");

   
    if(ps2x.Button(ORANGE_FRET)) // print stick value IF TRUE
    {
        Serial.print("Wammy Bar Position:");
        Serial.println(ps2x.Analog(WHAMMY_BAR), DEC);
    }
 }

 else { //DualShock Controller
 
    ps2x.read_gamepad(false, vibrate);          //read controller and set large motor to spin at 'vibrate' speed
   
    if(ps2x.Button(PSB_START))                   //will be TRUE as long as button is pressed
         Serial.println("Start is being held");
    if(ps2x.Button(PSB_SELECT))
         Serial.println("Select is being held");
         
         
     if(ps2x.Button(PSB_PAD_UP)) {         //will be TRUE as long as button is pressed
       Serial.print("Up held this hard: ");
       Serial.println(ps2x.Analog(PSAB_PAD_UP), DEC);
      }
      if(ps2x.Button(PSB_PAD_RIGHT)){
       Serial.print("Right held this hard: ");
        Serial.println(ps2x.Analog(PSAB_PAD_RIGHT), DEC);
      }
      if(ps2x.Button(PSB_PAD_LEFT)){
       Serial.print("LEFT held this hard: ");
        Serial.println(ps2x.Analog(PSAB_PAD_LEFT), DEC);
      }
      if(ps2x.Button(PSB_PAD_DOWN)){
       Serial.print("DOWN held this hard: ");
     Serial.println(ps2x.Analog(PSAB_PAD_DOWN), DEC);
     
     if(ps2x.Analog(PSS_LY))
     Serial.println(ps2x.Analog(PSS_LY), DEC);
     
     if((ps2x.Analog(PSS_LX), DEC) == 200)
         Serial.print("Analog works");
      }   
 
   
      vibrate = ps2x.Analog(PSAB_BLUE);        //this will set the large motor vibrate speed based on
                                              //how hard you press the blue (X) button   

    if (ps2x.NewButtonState())               //will be TRUE if any button changes state (on to off, or off to on)
    {


        if(ps2x.Button(PSB_L3))
         Serial.println("L3 pressed");
        if(ps2x.Button(PSB_R3))
         Serial.println("R3 pressed");
        if(ps2x.Button(PSB_L2))
         Serial.println("L2 pressed");
        if(ps2x.Button(PSB_R2))
         Serial.println("R2 pressed");
        if(ps2x.Button(PSB_GREEN))
         Serial.println("Triangle pressed");
         
    }   
         
   
    if(ps2x.ButtonPressed(PSB_RED))             //will be TRUE if button was JUST pressed
         Serial.println("Circle just pressed");
         
    if(ps2x.ButtonReleased(PSB_PINK))             //will be TRUE if button was JUST released
         Serial.println("Square just released");     
   
    if(ps2x.NewButtonState(PSB_BLUE))            //will be TRUE if button was JUST pressed OR released
         Serial.println("X just changed");   
   

 

 
   
    //if(ps2x.Button(PSB_L1) || ps2x.Button(PSB_R1)) // print stick values if either is TRUE
    {
     val = (ps2x.Analog(PSS_LY)); //venstre horisontalt
       val = map(val, 0, 1023, 0, 700);
         myservo.write(val);
     }
    {
     
     valx = (ps2x.Analog(PSS_LX)); //venstre vertikal
       valx = map(valx, 0, 1000, 20, 650);  //forskellig fra servo til servo
         myservox.write(valx);
     }
      {
     
     valy = (ps2x.Analog(PSS_RY)); //venstre vertikal
       valy = map(valy, 0, 1000, 20, 650);  //forskellig fra servo til servo
         myservoy.write(valy);
         
     }
      {
     
     valz = (ps2x.Analog(PSS_RX)); //venstre vertikal
       valz = map(valz, 0, 1000, 20, 650);  //forskellig fra servo til servo
         myservoz.write(valz);
 
    }
       
   
 }
 
 
 delay(50);
     
}
"Buy a man a beer and he wastes an hour. Teach a man to brew and he wastes a lifetime." :)

 

Offline Julle

  • Jordet Collector
  • *
  • Indlæg: 116
  • Antal brugbare Indlæg: 2
    • Vis profil
Sv: Hjælp til PSX controler på arduino
« Svar #6 Dato: Februar 23, 2015, 21:25:17 »
får denne fejl

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

 

Offline Jesper_Munkholm

  • µProcessoren
  • *
  • Indlæg: 380
  • Antal brugbare Indlæg: 36
  • Alt er Volt
    • Vis profil
Sv: Hjælp til PSX controler på arduino
« Svar #7 Dato: Februar 23, 2015, 22:17:30 »
ja nitte...

det er jo også til en ps2 den kode jeg havde fundet frem! men en ps2 trådløs (copy-china) kan købes på ebay til små penge!
jag købte denne her: http://www.ebay.com/itm/New-Black-Wireless-Shock-Game-Controller-for-Sony-PS2-Free-Shipping-/181591402157?pt=LH_DefaultDomain_15&hash=item2a47b0e6ad
"Buy a man a beer and he wastes an hour. Teach a man to brew and he wastes a lifetime." :)

 

Offline Julle

  • Jordet Collector
  • *
  • Indlæg: 116
  • Antal brugbare Indlæg: 2
    • Vis profil
Sv: Hjælp til PSX controler på arduino
« Svar #8 Dato: Februar 24, 2015, 08:07:52 »
ja så er der kun 2 muligheder ;-) enten så må jeg ud og købe en billig kina model eller se om ejg kan få den til det på en anden måde :-)

har ser en på DX.com til 83 kr det kunne godt være at det var den man skulle købe :-)

men min ide var bare at få en PS controller til at forbinde en en Arduino nano som så skulle sende infoen over en NRF24 eller en 433 mhz som så en arduino skulle kunne modtage

kunne være lidt fedt hvis man kunne få den til at køre med begge sender ;- )
Hilsen Klaus

 

Offline Julle

  • Jordet Collector
  • *
  • Indlæg: 116
  • Antal brugbare Indlæg: 2
    • Vis profil
Sv: Hjælp til PSX controler på arduino
« Svar #9 Dato: Februar 24, 2015, 14:00:45 »
ok så blev man lige lidt klogere :-)

der findes 2 typer af PSx controller (A og M)

http://www.slagcoin.com/joystick/pcb_diagrams/ps1_diagram8.jpg  type A

http://www.slagcoin.com/joystick/pcb_diagrams/ps1_diagram5.jpg type M

så er det bare at få lave lidt om på min tror jeg :-S
Hilsen Klaus