when i press the cross button on my ps4 button it doesn't move the motor
i measure the voltage m1a it draw less then the others (m1b, m2a and m2b)
the motor work fine when manually tested and my ps4 controller
- CODE: SELECT_ALL_CODE
#include <PS4BT.h>
#include <usbhub.h>
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif
#include <SPI.h>
USB Usb;
BTD Btd(&Usb);
PS4BT PS4(&Btd, PAIR);
#define dir_1 5
#define pwm_1 6
#define dir_2 8
#define pwm_2 9
void setup() {
Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start"));
while (1); // Halt
}
Serial.print(F("\r\nPS4 Bluetooth Library Started"));
pinMode(dir_1, OUTPUT);
pinMode(pwm_1, OUTPUT);
pinMode(dir_1, OUTPUT);
pinMode(pwm_2, OUTPUT);
}
void loop() {
Usb.Task();
if(PS4.connected()){
Serial.print(F("\nPS4 connected"));
if(PS4.getButtonPress(CROSS)){
analogWrite(pwm_1, 100);
digitalWrite(dir_1, LOW);
}
if(PS4.getButtonPress(TRIANGLE)){
analogWrite(pwm_1, 150);
digitalWrite(dir_1, HIGH);
}
else {
analogWrite(pwm_1, 0);
analogWrite(pwm_2, 0);
}
if(PS4.getButtonPress(UP)){
analogWrite(pwm_2, 150);
digitalWrite(dir_2, HIGH);
}
if(PS4.getButtonPress(DOWN)){
analogWrite(pwm_2, 150);
digitalWrite(dir_2, LOW);
}
if (PS4.getButtonClick(PS)) {
Serial.print(F("\r\nPS disconnected"));
PS4.disconnect();
Serial.end();
}
}
}