Closed dragzor55 closed 6 years ago
@dragzor55 first of all you should check if the PS4 controller is actually connected. The reason why your code does not work is because you are setting the PWM pins low in every loop. Also you probably want to use the getButtonPress
function instead, as it will return true as long as the button is pressed.
Here is a minimal example:
void loop() {
Usb.Task();
if (PS4.connected()) {
if (PS4.getButtonPress(L1)) {
analogWrite(pwmPin, 127);
} else {
analogWrite(pwmPin, 0);
}
} else {
analogWrite(pwmPin, 0);
}
}
I am entering a robotics competition and need help with the "getButtonClick". We are using an Arduino to produce pwm signals to run the motor controllers. I have managed to get the back triggers to move the robot forward these use the "getAnalogButton". Yet when I try to use the L3 and R3 buttons on the controller w/ the "getButtonClick", nothing happened. To troubleshoot I've put "PS4.setLed(Red);" to the if statement. The LED did in fact turn red, but no pwm signal was made. Also, if someone could help me understand how to implement joysticks into the drive control of the robot, then that would be incredibly helpful.