I am building a quadcopter drone and I have 4 BLDC motors that I can control using an HM10 Bluetooth module and the "Dabble" application. My problem is that when I use a virtual joystick in the "gamepad" module of the Dabble application to control the speed of the motors, it seems to be limited to 2 or 3 speeds. The joystick module that I am using is supposed to have values of 0 to 7 depending on the distance of the joystick from its center. Yet the motor only moves once the joystick is halfway away from center, and then it only spins at a couple different speeds when I push the joystick further. Here is my code:
#include <Servo.h> //Servo library
#include <Dabble.h> //Dabble library for bluetooth connection
#define INCLUDE_GAMEPAD_MODULE //Includes Dabble Gamepad module
#define CUSTOM_SETTINGS
Servo ESC1; //define the 4 motors
Servo ESC2;
Servo ESC3;
Servo ESC4;
int Speed; //create a variable for speed of motors
void setup() {
Dabble.begin(9600); //Set the baud rate for the HM10 to 9600
ESC1.attach(9); //Set the motors to their corresponding pins on the arduino
ESC2.attach(10);
ESC3.attach(11);
ESC4.attach(12);
}
void loop() {
Dabble.processInput(); //Refresh information from the Dabble application
Speed = GamePad.getRadius(); //Get a value from the Dabble application corresponding to the distance of the joystick from center (0 to 7)
Speed = map(Speed, 0, 7, 0, 180); //translate the value from the Dabble application (0 to 7) into the "language" of the motors (0 to 180)
ESC1.write(Speed); //Set the motors to the new speed
ESC2.write(Speed);
ESC3.write(Speed);
ESC4.write(Speed);
}
-
3Can you check what values the Dabble application actually sends? That might show us on which side the problem is.chrisl– chrisl2023年11月08日 21:06:03 +00:00Commented Nov 8, 2023 at 21:06
-
that sounds like a good idea but I am not too sure how to go about that. The dabble app is on my phone and I cannot have my laptop connected to the arduino while this is running as apparently it will fry the USB portgabe29– gabe292023年11月09日 00:43:09 +00:00Commented Nov 9, 2023 at 0:43
-
1Update: I'm silly, I can simply unplug the motor and then read the data while connected to my laptop. Turns out the arduino is receiving all values 0 through 7 as intended. The problem must be with the BLDC somehow.gabe29– gabe292023年11月09日 01:11:18 +00:00Commented Nov 9, 2023 at 1:11