Open Genesiscode99 opened 6 months ago
why do you think this is a Bluepad32 issue ? (perhaps it is, perhaps it is not).
In any case, DO NOT attach photos. Attach the code.
// Define the number of servo motors
// Define the servo parameters
// Create an array of servo objects Adafruit_PWMServoDriver pwm[NUM_SERVOS];
// Map joystick values to servo angle int mapJoystickToServo(int value) { // Map joystick values (-511 - 512) to servo angle (180 - 0) // Reverse the mapping to move from right to left return map(value, -511, 512, SERVO_MAX_ANGLE, SERVO_MIN_ANGLE); }
// Define SDA and SCL pins
void processGamepad(ControllerPtr ctl) { // Read joystick's horizontal axis int joystickX = ctl->axisX();
// Map joystick value to servo angle
int servoAngle = mapJoystickToServo(joystickX);
// Set servo positions for all servo motors
for (int i = 0; i < NUM_SERVOS; i++) {
pwm[i].setPWM(0, 0, servoAngle); // Adjust pin number if needed
}
}
void onConnectedController(ControllerPtr ctl) { // Print controller connected message Serial.printf("Controller connected: %s\n", ctl->getModelName().c_str()); }
void onDisconnectedController(ControllerPtr ctl) { // Print controller disconnected message Serial.printf("Controller disconnected: %s\n", ctl->getModelName().c_str()); }
void setup() { // Initialize serial communication Serial.begin(115200);
// Initialize I2C communication
Wire.begin(SDA_PIN, SCL_PIN); // Initialize I2C with specified SDA and SCL pins
// Initialize Bluepad32
BP32.setup(&onConnectedController, &onDisconnectedController);
// Initialize all servo drivers
for (int i = 0; i < NUM_SERVOS; i++) {
pwm[i].begin();
pwm[i].setPWMFreq(60); // Set the PWM frequency to 60Hz
}
}
void loop() { // Update Bluepad32 BP32.update();
// Add a small delay to prevent overwhelming the system
delay(20);
}
I mean I don't actually know if it's bluepad32 I'm probably just missing something I don't know.
I guess you never reported a bug before... so welcome to the world of reporting bugs.
I’m on Arduino ide I got my ps4 controller to connect to my ESP32 and the sketch uploads with no errors. Wiring and everything is good too but The joy sticks is not controlling the servo motors.