0

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);
}
asked Nov 8, 2023 at 20:51
3
  • 3
    Can you check what values the Dabble application actually sends? That might show us on which side the problem is. Commented 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 port Commented Nov 9, 2023 at 0:43
  • 1
    Update: 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. Commented Nov 9, 2023 at 1:11

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.