Introduction: How to Run a Brushless Motor ESC With Arduino

Picture of 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

Picture of 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

Picture of 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.

//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(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



SurenMax (author)2017-12-14

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.

Bigj634 (author)2017-11-27

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

JavedA28 (author)2017-07-02

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



void loop()


int val; //Creating a variable val

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

RinzinMake (author)JavedA282017-08-18

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

RinzinMake (author)2017-08-18

How should I connect 4 brushless motor in arduino UNO ?

MichaelM1274 (author)2017-07-21

can i use esc and brushless motor for a autonomous sumobot

PiFailDuino (author)MichaelM12742017-08-08

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: 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: 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!

IkramA7 (author)2017-05-24

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


lipo 11.1v 2200mah

SagarS115 (author)IkramA72017-06-22

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




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

rwittoz (author)2017-05-21


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

swaroop1196 (author)2017-04-24

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

what to do?

sailorjohn34 (author)2017-01-18

#include Servo ESC1;

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

MikeE120 (author)sailorjohn342017-01-26

Just try this:

#inclue <Servo.h>
Servo ESC1;

soilwork (author)2015-05-18

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

sailorjohn34 (author)soilwork2017-01-18

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.

soilwork (author)sailorjohn342017-01-18

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.

dvyas (author)soilwork2016-08-07

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.

muhammadi41 made it! (author)2016-08-31

i have Esc and brush-less motor of dji phantomSo can i connect the esc and brush-less motor of dji phantom2 to arduino, like how to control using arduino.
if that's possible what are the connections.

devandlal (author)2016-02-10

can u please give me the code for the above drone

Ripunjoy Choudhury (author)2016-01-05

Thank you!!

minitotent (author)2015-06-07

I know my airplane ESC can go up to 90% (I hooked up an oscilloscope to the transmitter and that's the duty cycle output it was showing).

You should also note that you can hook up a servo almost identically (add a 3.3-6V power source to the power cord and connect all the grounds together) and setting different speeds will make the servo move as well. You made a pretty useful tutorial and I would consider adding the brushless motor part you have in your intro sentence to the title.

wcamammoths (author)minitotent2016-01-04

Thanks. I added "brushless motor" to the title. Great idea!

heyitsmekarthi (author)2015-08-15

For getting beeps in esc means it went to programming mode, one rule for using esc is it must be switched ON without throttle(here zero input), after connecting you can gradually vary the speed

pritesh_pj (author)2015-05-17

Doesnt work for me..
ESC : 30A
Battery : 12V , 2200mAh Li-ion
The connections are proper. just some beeps repeating itself...but the motor dosent start.
where could I be going wrong??

P.S : Syntax error :

Servo esc;

wcamammoths (author)pritesh_pj2015-05-20

It could be the way the ESC is wired to the motor, when I was experimenting with different wiring configurations of the 3 wires, if they are not connected in the right way, the motor just beeps, like you said. I hope this helps.

pritesh_pj (author)wcamammoths2015-05-22

actually some days back once the motor had worked. i did it using the servo library to simply run for a few seconds gradually increasing the speed and then decreasing it .But it isnt working now even if i use the same code...or any other code like yours..

could it be that something has burned inside my esc?

wcamammoths (author)pritesh_pj2015-07-16

It's impossible to say without being there. There are numerous things that could cause the motor not to spin. Bad arduino, bad esc, bad motor, bad code, bad soldering, bad wire, etc. You'll just have to test them one by one to see which is the culprit.

if the syntax error is something like "fatal error: Servo.h: No such file or directory" the problem is that you don't have the Servo.h library installed correctly! You can check by clicking on the tab "sketch" of the arduino IDE and than "include library", if you don't see a line that says "Servo" it means that you have to install the library, it's easier to download the latest arduino IDE (1.6.something) from the arduino website, the library is included by default

NO such issue. i have been working with servo library for quite some time now... there's nothing wrong with it.
Still thanks for your concern.

Thanks, MatteoF2, great answer.

SamuelHoffmann (author)2015-06-09

First of all I was wondering if you got the gyroscope working in sync with the motors having it balance? Also one problem with the esc heating up is that you don't need to provide power to the esc with the three pins the batter hooked up to it will provide enough with the wire to 5v you will just melt you esc and your Arduino to liquid

SamuelHoffmann (author)2015-06-09

First of all I was wondering if you got the gyroscope working in sync with the motors having it balance? Also one problem with the esc heating up is that you don't need to provide power to the esc with the three pins the batter hooked up to it will provide enough with the wire to 5v you will just melt you esc and your Arduino to liquid

billbucket (author)2015-05-15

Get some shrink tube, or at least some electrical tape. That thing is a fire hazard.

wcamammoths (author)billbucket2015-05-15

Thanks for the comment, Bill. We took the electrical tape off for the photographs. We agree that it would be unsafe to fly without it.

About This Instructable



Bio: 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 ... More »
More by wcamammoths:1000 mw Laser Engraver Below $100Raspberry Pi Smart Doorbell: Who's at My Door?Variable Voltage Power Supply <$15
Add instructable to: