How to Run a Brushless Motor ESC With Arduino

105,070

264

34

About: The Western Center Academy is a STEM Charter in Hemet, CA. Our high school students take a course called "STEM Studio" in which they first build a project from Instructables, then they create a project to u...

Intro: How to Run a Brushless Motor ESC With Arduino

This instructable will show you how to configure and run a brushless motor ESC with an arduino and run a brushless motor at different speeds. It will go through the materials, setup of hardware, and the software coding. It will explain what each step in the coding does. Don't get hurt and have fun!

Here is a video of the motors working.

Step 1: Obtain Your Materials

You will need to get:

Arduino (Any will do, I used an Arduino Mega)

Computer with Arduino Coding program on it.

USB connector

ESC (Any will do, I used a generic brand at 30 AMPs)

A 10 AMP brushless motor,

Connector wires

Soldering iron w/ Solder

Battery (Any battery that is 12 volts, is 2 or more cells, I used a 3 cell 11.1 volt battery)

Step 2: Wiring and Hardware Setup

- Plug in the soldering iron to warm it up then line up the ESC with the motors wires (The ESC’s wires should have three of the same exact wires on one side, the other side is for the battery and Arduino)

- Once the soldering iron is heated, put the motor control wires going out of the ESC together with the wires going out of the motor. The middle wires have to go together, but the 2 side wires can be switched to reverse the direction of the motor. Finally, you need to use the soldering iron to warm-up the wires, this should take about 5-10 seconds, then melt the solder on the wires to bond them together.

- Take the input wire from the esc (The one that looks like a servo wire) and attach the ground to ground and the signal (white) to pin 9. The positive wire should be connected to vin ONLY if the arduino is not connected to the computer. If it is connected to the computer, do not attach the positive wire to anything or it will burn out your your computer

- The thick red and black wires coming out the bottom should be connected to the battery.

Step 3: Software/Coding

- You will need to plug your arduino board into the computer with the USB connector first. Then, you can download the below program. After the program is downloaded, press the reset button on the arduino before plugging the battery into the ESC. The motor will make a start up noise, then it will wait. After a few seconds, the motor will beep 3 times and then gradually move to the speed programed. It will then gradually move back down to zero speed. You can edit the program for how fast the motors go and how long they stay on. Do not set the motors to a speed above 85% power or the ESC will burn out.

Code)
//This code can be used for any purpose.

#include Servo ESC1;

int pos = 0; //Sets position variable

void arm(){

setSpeed(0); //Sets speed variable delay(1000);

}

void setSpeed(int speed){

int angle = map(speed, 0, 100, 0, 180); //Sets servo positions to different speeds ESC1.write(angle);

}

void setup() {

ESC1.attach(9); //Adds ESC to certain pin. arm();

}

void loop() {

int speed; //Implements speed variable

for(speed = 0; speed <= 70; speed += 5) { //Cycles speed up to 70% power for 1 second

setSpeed(speed); //Creates variable for speed to be used in in for loop

delay(1000);

}

delay(4000); //Stays on for 4 seconds

for(speed = 70; speed > 0; speed -= 5) { // Cycles speed down to 0% power for 1 second

setSpeed(speed); delay(1000);

}

setSpeed(0); //Sets speed variable to zero no matter what

delay(1000); //Turns off for 1 second

}

Share

Recommendations

  • Metalworking Contest

    Metalworking Contest
  • Audio Contest 2018

    Audio Contest 2018
  • Furniture Contest 2018

    Furniture Contest 2018

34 Discussions

0
None
JavedA28

1 year ago

Hi, this is another method I know please review this that it wouldn't hurt any component:

esc.writeMicroseconds(1000); //initialize the signal to 1000

Serial.begin(9600);

}

void loop()

{

int val; //Creating a variable val

esc.writeMicroseconds(val); //using val from 1000-2000

2 replies
0
None
RinzinMakeJavedA28

Reply 1 year ago

sir can you please teach me how to connect 4 brushless motor in a arduino UNO

0
None
SurenMax

9 months ago

Hi, this is the first time I'm using a brushless motor. Is it possible to make the motor spin in opposite direction using this method? Thanks in advance.

0
None
Bigj634

9 months ago

I think i did it right. For me it beeps once then 2 seconds later it just beeps over and over any guess what the problem might be. Thx in advance

0
None
RinzinMake

1 year ago

How should I connect 4 brushless motor in arduino UNO ?

0
None
PiFailDuinoMichaelM1274

Reply 1 year ago

You can, but its not recommended, because they consume a lot of power, like 20-40 Amps and they are quite big for a mini sumo or something like that. i would recommend a small motor with a reductor/gearbox attached to it. A brushed DC Motor can consume like 0.5-3A, so, i would suggest a brushed motor instead of a brushless, but yes you can and if you're gonna go the brushless motor route i would suggest a 2100Kv brushless motor from Hobbyking like this one: https://hobbyking.com/en_us/turnigy-1-8th-scale-4-pole-brushless-motor-2100kv.html and you would need a powerful esc for it, because this motor can draw around 80A continuously and that can cost way more then a DC motor. And if you want to go the DC motor route I would suggest a brushed motor with a gearbox like this one: https://hobbyking.com/en_us/brushed-motor-15mm-6v-20000kv-w-30-1-ratio-gearbox.html these ones are powerful, fast and pretty power efficient and well, i'm building a Mini Sumo robot myself and i use these ones. I hope i answered your question and take care!

0
None
IkramA7

1 year ago

hello i did every thing that you said and still it did not work just some beeps and that's all can you help me

esc:30a

lipo 11.1v 2200mah

1 reply
0
None
SagarS115IkramA7

Reply 1 year ago

Hello IkramA7,

There are some trivial mistakes in the code if you have it blindly it causes trouble. To list

#include <Servo.h>

which I think you have corrected since it compiled and beeped.

Parts of code have been commented

delay(1000);

ESC1.write(angle);

arm();

Just put them back in code I guess it'll work

0
None
rwittoz

1 year ago

Hello

You can use this method for ESC compatible with reverse and brake ?

0
None
swaroop1196

1 year ago

it is showing "This library only supports esp8266 boards."

what to do?

0
None
sailorjohn34

1 year ago

#include Servo ESC1;

The above line doesn't compile. I am tinkering with it now to see what I can come up with.

1 reply
0
None
soilwork

3 years ago

I hope someone can help me with this question because I'm only worked few times with brushless motors. I'm planning to use a Rc brushless motor like yours to make it work as a diy cnc spindle for drilling and routing pcb and stuffs like that, so my question is, Do any rc brushless motor will do the job?
i meant a good job talking about torque and speed, no loosing to much speed or torque when the bit start drilling

3 replies
0
None
sailorjohn34soilwork

Reply 1 year ago

I noticed this post is 2 years old. What did you end up going with? If you can get ahold of something like the drive system in one of those rotozip tools, They have the speed, torque (thru gears) and they are dc so that's a nice advantage. I prefer to keep as much DC as possible so as to avoid getting zapped.

0
None
soilworksailorjohn34

Reply 1 year ago

Now I use dremel but I leave the brushless option behind because now I made my pcb's using the spray paint and laser technique, its very accurate with a 0.2mm laser dot, It uses a 2w 445nm laser on a cnc to burn the black paint of the pcb surface and then etch with the sponge etching metodth.

0
None
dvyassoilwork

Reply 2 years ago

Use larger BLDC with lower KV rating. 580 KV etc lower kv =higher torque. Hook it up with Amplifiers step down transform and with good quality filter circuit. Google it you wil find.

0
None
devandlal

2 years ago

can u please give me the code for the above drone