aed3 / PS4-esp32

Use a ps4 controller with an esp32
334 stars 104 forks source link

Ask questions,Thanks! #8

Open iotPeanut opened 3 years ago

iotPeanut commented 3 years ago

Hello, I'm sorry to trouble you. I'm using the ps4controller library to control my PS4. Follow the steps in the tutorial you wrote, but Bluetooth has been unable to connect the two.

When I use sixaxpairtool to set Mac, the display is set successfully. But when I search the Bluetooth of PS4 on my mobile phone, the MAC address displayed is different from that I set with sixaxpairtool. The ESP hardware board I used is ttgo T1 and esp32 dev module, both of which can not be tested. The esp32 chip of the latter is esp32-wroom-32. The code is as follows:

include

include

void onConnection() { if (PS4.isConnected()) { Serial.println("Controller connected."); } } char mac = (char)"98:b6:e9:9c:fd:da";//my phone display MAC void setup() { Serial.begin(115200);

//SerialBT.begin("ESP32tes3t"); //蓝牙模块名称

// Serial.println("The device started, now you can pair it with bluetooth!"); //"01:02:03:04:05:06" if(!PS4.begin(mac)) { Serial.println("Initializetion failed"); return; } Serial.println("Ready6."); PS4.attachOnConnect(onConnection); }

void loop() { // Below has all accessible outputs from the controller if(PS4.isConnected()) { Serial.println("Connected!"); if ( PS4.data.button.up ) Serial.println("Up Button"); if ( PS4.data.button.down ) Serial.println("Down Button"); if ( PS4.data.button.left ) Serial.println("Left Button"); if ( PS4.data.button.right ) Serial.println("Right Button");

        if ( PS4.data.button.upright )
                Serial.println("Up Right");
        if ( PS4.data.button.upleft )
                Serial.println("Up Left");
        if ( PS4.data.button.downleft )
                Serial.println("Down Left");
        if ( PS4.data.button.downright )
                Serial.println("Down Right");

        if ( PS4.data.button.triangle )
                Serial.println("Triangle Button");
        if ( PS4.data.button.circle )
                Serial.println("Circle Button");
        if ( PS4.data.button.cross )
                Serial.println("Cross Button");
        if ( PS4.data.button.square )
                Serial.println("Square Button");

        if ( PS4.data.button.l1 )
                Serial.println("l1 Button");
        if ( PS4.data.button.r1 )
                Serial.println("r1 Button");

        if ( PS4.data.button.l3 )
                Serial.println("l3 Button");
        if ( PS4.data.button.r3 )
                Serial.println("r3 Button");

        if ( PS4.data.button.share )
                Serial.println("Share Button");
        if ( PS4.data.button.options )
                Serial.println("Options Button");

        if ( PS4.data.button.ps )
                Serial.println("PS Button");
        if ( PS4.data.button.touchpad )
                Serial.println("Touch Pad Button");

        if ( PS4.data.button.l2 ) {
                Serial.print("l2 button at ");
                Serial.println(PS4.data.analog.button.l2, DEC);
        }
        if ( PS4.data.button.r2 ) {
                Serial.print("r2 button at ");
                Serial.println(PS4.data.analog.button.r2, DEC);
        }

        if ( PS4.event.analog_move.stick.lx ) {
                Serial.print("Left Stick x at ");
                Serial.println(PS4.data.analog.stick.lx, DEC);
        }
        if ( PS4.event.analog_move.stick.ly ) {
                Serial.print("Left Stick y at ");
                Serial.println(PS4.data.analog.stick.ly, DEC);
        }
        if ( PS4.event.analog_move.stick.rx ) {
                Serial.print("Right Stick x at ");
                Serial.println(PS4.data.analog.stick.rx, DEC);
        }
        if ( PS4.event.analog_move.stick.ry ) {
                Serial.print("Right Stick y at ");
                Serial.println(PS4.data.analog.stick.ry, DEC);
        }

 if (PS4.data.status.charging)
    Serial.println("The controller is charging");
 if (PS4.data.status.audio)
    Serial.println("The controller has headphones attached");
 if (PS4.data.status.mic)
    Serial.println("The controller has a mic attached");

 Serial.print("Battey Percent : ");
 Serial.println(PS4.data.status.battery, DEC);

     Serial.println();
     // This delay is to make the Serial Print more human readable
     // Remove it when you're not trying to see the output
 delay(1000);
}

} I understand that the Bluetooth version of PS4 is Bluetooth ver2.1 + EDR. Do you know if it is compatible with esp32 Bluetooth? Thank you, thank you for taking the time to answer the questions, thank you!