所以,我正在尝试用一些伺服系统和一个 Esp32 开发板构建一个四足机器人。所有硬件都必须由 PS4 控制器控制。但是 Esp32 到 Ps4 的连接有问题。例如,当我按下 L2 按钮时,程序会显示“按下 R2 按钮”。
这是我上传的测试代码。
#include <PS4Controller.h> void setup() { Serial.begin(115200); PS4.begin("03:03:03:03:03:03"); Serial.println("Ready."); } void loop() { // Below has all accessible outputs from the controller if (PS4.isConnected()) { if (PS4.Right()) Serial.println("Right Button"); if (PS4.Down()) Serial.println("Down Button"); if (PS4.Up()) Serial.println("Up Button"); if (PS4.Left()) Serial.println("Left Button"); if (PS4.Square()) Serial.println("Square Button"); if (PS4.Cross()) Serial.println("Cross Button"); if (PS4.Circle()) Serial.println("Circle Button"); if (PS4.Triangle()) Serial.println("Triangle Button"); if (PS4.UpRight()) Serial.println("Up Right"); if (PS4.DownRight()) Serial.println("Down Right"); if (PS4.UpLeft()) Serial.println("Up Left"); if (PS4.DownLeft()) Serial.println("Down Left"); if (PS4.L1()) Serial.println("L1 Button"); if (PS4.R1()) Serial.println("R1 Button"); if (PS4.Share()) Serial.println("Share Button"); if (PS4.Options()) Serial.println("Options Button"); if (PS4.L3()) Serial.println("L3 Button"); if (PS4.R3()) Serial.println("R3 Button"); if (PS4.PSButton()) Serial.println("PS Button"); if (PS4.Touchpad()) Serial.println("Touch Pad Button"); if (PS4.L2()) { Serial.printf("L2 button at %d\n", PS4.L2Value()); } if (PS4.R2()) { Serial.printf("R2 button at %d\n", PS4.R2Value()); } if (PS4.LStickX()) { Serial.printf("Left Stick x at %d\n", PS4.LStickX()); } if (PS4.LStickY()) { Serial.printf("Left Stick y at %d\n", PS4.LStickY()); } if (PS4.RStickX()) { Serial.printf("Right Stick x at %d\n", PS4.RStickX()); } if (PS4.RStickY()) { Serial.printf("Right Stick y at %d\n", PS4.RStickY()); } if (PS4.Charging()) Serial.println("The controller is charging"); if (PS4.Audio()) Serial.println("The controller has headphones attached"); if (PS4.Mic()) Serial.println("The controller has a mic attached"); Serial.printf("Battery Level : %d\n", PS4.Battery()); Serial.println(); // This delay is to make the output more human readable // Remove it when you're not trying to see the output delay(1000);