How to control 2 Brushless DC Motor with ESC via bluetooth.

Here is my current code, and im struggling to put these two brushless motor because i dont know how to insert them on my program. I’m using l293d shield with 4 motors. Thanks in advance. See my code below.

#include <AFMotor.h>

AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

String readString;

void setup() {
Serial.begin(9600);
motor1.setSpeed(250);
motor2.setSpeed(250);
motor3.setSpeed(250);
motor4.setSpeed(250);

}

void loop() {

while (Serial.available()) {
delay(50);
char c = Serial.read();
readString += c;
}

if (readString.length() > 0) {
Serial.println(readString);
if (readString == “FWD”) {
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
delay(500);
}
}
if (readString.length() > 0) {
Serial.println(readString);
if (readString == “RVS”) {
motor1.run(BACKWARD);
motor2.run(BACKWARD);
motor3.run(BACKWARD);
motor4.run(BACKWARD);
delay(500);
}
if (readString.length() > 0) {
Serial.println(readString);
if (readString == “LEFT”) {
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(RELEASE);
motor4.run(RELEASE);
delay(500);
}
if (readString.length() > 0) {
Serial.println(readString);
if (readString == “RIGHT”) {
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(FORWARD);
motor4.run(FORWARD);
delay(500);
}
if (readString.length() > 0) {
Serial.println(readString);
if (readString == “STOP”) {
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
delay(500);
}

readString = “”;
}
}
}
}
}

I’m using l293d shield with 4 motors

What type of motors are these 4 ?

Brushless motors/ESCs are normally driven using code similar to driving a servo i.e. using Servo.h library.

Google "brushless ESC arduino" for many examples of how it is done.

Steve

UKHeliBob: What type of motors are these 4 ?

they are 4 brushed dc motor and i dont have problems with them. only problem is that i dont know how does the code for controlling the brushless with bluetooth

slipstick: Brushless motors/ESCs are normally driven using code similar to driving a servo i.e. using Servo.h library.

Google "brushless ESC arduino" for many examples of how it is done.

Steve

i've seen some but they are only for 1 brushless motor and i can't control them via bluetooth, that's why im asking if someone could provide me with a code

ibenzzz: i've seen some but they are only for 1 brushless motor and i can't control them via bluetooth, that's why im asking if someone could provide me with a code

Use a separate ESC for each brushless motor and treat them as servos. The higher the "angle" written to the ESC the faster that the motor will turn.

As a matter of interest, how are you powering the system and the motors in particular ?

I'm using Nimh 8AA for my brushless and it works. and i'm gonna be using normal AA for my 4 other motors and 9v for the arduino

ibenzzz: only problem is that i dont know how does the code for controlling the brushless with bluetooth

You control stuff with Bluetooth by connecting your Bluetooth module and sending messages from the controller to the Bluetooth module. Usually that arrives at the Arduino in the form of a serial data stream, just like Serial. Your sketch receives the bytes from the controller and figures out what to do from there. Have you designed the controller yet?