Introduction: 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
}

Participated in the
Move It
39 Comments
5 years 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.
Reply 4 years ago
I have been building model planes and drones with brushless motors. Sorry to say no you can't, not without a special esc.
Reply 4 years ago
You only have to exchange two of the cables that leave the ESC and connect to the brushless motor. If you use a switch with two poles and two positions, maybe you could change from one rotation direction to another in a simpler way. I believe that you can not change the direction of rotation energized the whole system. You turn off, change the position of the cables and start the system again. I hope I have clarified you. regards
Question 4 years ago on Step 3
Where did this library come from?
#include Servo ESC1
Answer 4 years ago
I believe that it was a mistake and should say,
#include <Servo.h>
Servo ESC1;
ESC1 is just the name that was chosen for that servo.
8 years ago
Get some shrink tube, or at least some electrical tape. That thing is a fire hazard.
Reply 4 years ago
Exact thoughts when i saw it.
Reply 8 years ago
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.
5 years 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
Reply 5 years ago
sir can you please teach me how to connect 4 brushless motor in a arduino UNO
Reply 5 years ago
Di u finish ur drone sir ?
5 years 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
5 years ago
How should I connect 4 brushless motor in arduino UNO ?
5 years ago
can i use esc and brushless motor for a autonomous sumobot
Reply 5 years 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!
6 years 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
Reply 5 years 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
6 years ago
Hello
You can use this method for ESC compatible with reverse and brake ?
6 years ago
it is showing "This library only supports esp8266 boards."
what to do?
6 years ago
#include Servo ESC1;
The above line doesn't compile. I am tinkering with it now to see what I can come up with.