Introduction: Interfacing Brushless DC Motor (BLDC) With Arduino

This is a tutorial about how to interface and run a Brushless DC motor using Arduino. If you have any questions or comments please reply in comments or mail to rautmithil[at]gmail[dot]com. You can also get in touch with me @mithilraut on twitter.

To know more about me: www.mithilraut.com

Step 1: List of Components

  1. Arduino UNO
  2. BLDC outrunner motor (Any other outrunner motor will work fine)
  3. Electronic Speed Controller (Choose according to the current rating of the motor)
  4. LiPo Battery (to power the motor)
  5. Male-Male Jumper cable * 3
  6. USB 2.0 cable type A/B (To upload the program and power the Arduino).

Note: Make sure you check the connectors of battery, ESC and Motors. In this case we have 3.5mm male bullet connectors on the Motor. So I soldered 3.5mm female bullet connectors on the output of ESC. The Battery had a 4.0mm Male Female connector. Hence I soldered appropriate female male connectors on the input side of ESC.

Step 2: Connections

Connect the motor to the output of ESC. Here, the polarity doesn't matter. If you switch any 2 of the 3 wires, the motor will rotate in opposite direction.

Connect the '+' & '-' of battery to the Red(+) and Black(-) wires of ESC respectively.

From the 3pin servo cable coming out of the ESC, connect the Brown cable to the 'GND' pin on Arduino. Connect the Yellow cable to any digital pin. In our case its digital pin 12.

Step 3: Programming Arduino UNO

If you are new to Arduino then you can download, install and setup the Arduino from here.

Connect the Arduino to the PC. Open Arduino IDE and write this code. Under 'Tools' select

Board: Arduino/Genuino UNO

Port: COM15 (Select appropriate COM port. To find out the COM port open device manager and look for Arduino UNO under 'Ports')

Click Upload button on the upper left corner.

#include <Servo.h>
Servo esc_signal;

void setup()
{
  esc_signal.attach(12);  //Specify here the pin number on which the signal pin of ESC is connected.
  esc_signal.write(30);   //ESC arm command. ESCs won't start unless input speed is less during initialization.
  delay(3000);            //ESC initialization delay.
}

void loop()
{
esc_signal.write(55);	  //Vary this between 40-130 to change the speed of motor. Higher value, higher speed.
delay(15);
}

Step 4: Note

The correct way to run the motors is to

1. Connect the battery to the ESC to power up the ESC.

2. Power the Arduino.

If you do the other way round, the Arduino will run the arm sequence and the ESC will miss those commands since it isn't powered up. In this case press the reset button on the Arduino.

Comments

author
KarlH61 (author)2017-08-04

Arduino has only ground and signal wire connected from ESC BEC in diagram. Is Arduino being powered by the signal wire? Or is the power to the Arduino not in the diagram? (As far as I know the BEC power wire is 5v so that could power Ard.)

author
KarlH61 (author)2017-08-03

Am running a brushless turbine as part of a Porsche 911 AC system. All the sketches I've looked at to arm and then run the turbine at a prescribed speed have been far more complicated. The simplicity of this is beautiful. Am looking forward to get Arduino and test run sketch. Thanks for posting this Mithil.

author
gokul25 (author)2017-05-26

Sir I did the same connections bt my motor is not rotating .help me

author
user8206 (author)gokul252017-08-03

try changing the speed of the motor. mine did not work for 55. it worked when I changed it to 85.

in the loop

esc_signal.write(85);

author
Saransh_mahima (author)gokul252017-06-11

Maybe my post will help you... Take a look

author
user8206 (author)2017-08-03

works great. thanks so much!

author
Garvit Pandya (author)2017-03-07

Can we vary the speed of the motor with arduino itself? Or we need to add any component to do so?

author
MithilR (author)Garvit Pandya2017-03-07

You can vary the speed by the changing the value in this command.

esc_signal.write(55);

Vary this value between 40-130 to change the speed of motor from minimum to maximum.

No extra hardware required except the ones mentioned in this instructable.

author
Garvit Pandya (author)MithilR2017-03-15

Umm.... I have another question.

In what you have done, you have not connected the laptop or computer for operation. In this condition, I will need to connect and disconnect, edit program and load and do all the connection and operate the motor. Right?

How to do it the either way?

I want to keep the arduino connected to my computer and then change the coding that is motor speed variation at my requirement.

Like, once I operate it at 40 and then I want to operate it at 100, I want to do this change in the program with all the connections as it is, just by resetting the arduino and uploading the program and operate.

author
Garvit Pandya (author)MithilR2017-03-07

Ok. That is pretty good. Now the other question bumped into my mind this morning. Can we connect LiPo battery directly to Arduino? Because I have heard from many people that we can only connect our laptop or computer with Arduino to provide power supply. Guide me in that case too.

author
MithilR (author)Garvit Pandya2017-03-07

The board can be supplied with external power from the DC power jack (7 - 12V). If the lipo battery has voltage between 7-12V you can connect it to the DC power jack on Arduino Uno or similar boards. DC power jack is the black cylinder on board with a pin in it.

author
Garvit Pandya (author)MithilR2017-03-07

Ok. I understood. So, If I want to do the copy of what you have done, I can connect battery using ESC, so it won't affect the Arduino board. Correct? And, it seems, if I want to control or vary the speed of the motor, I may need something like potentiometer. So, it can vary as per the requirement physically.

One more thing. We can also connect Receiver here with the board and then use the Remote control and vary the speed of the motor. That will be sort of similar to what we do when we fly a quadcopter using some other flight controller board. What is your opinion?

author
MithilR (author)Garvit Pandya2017-03-09

Yes to the first paragraph of concerns/questions.

If you have a receiver, then you don't need the Arduino. You can connect the ESC with the receiver instead of Arduino and use the Remote Control (a.k.a Transmitter) to control the speed.

author
Garvit Pandya (author)2017-03-07

Good job. Got the program too. Thank you!

author
yogesh645 (author)2017-02-04

My project is based on controlling the quadcopter with the help of mindwave mobile. Can you tell me how to control servomotors with mindwave mobile?

author
MithilR (author)yogesh6452017-02-06

Look into interfacing the mindwave with an Arduino. From there its the same as mentioned in the tutorial.

author
fly_with_me (author)2017-01-07

Hey, great tutorial! I was wondering, if i wanted to connect two motors, would i ground them both to the same gnd slot on the arduino? and connect the yellow wire to another number, say 11?

author
MithilR (author)fly_with_me2017-01-19

Yes. That will work.

author
LP700-4 (author)2016-08-10

My ESC has a black, red and white wires witch ones should I connect where on the UNO?

author
MithilR (author)LP700-42016-12-25

By color convention in electrical systems, black goes to GND, red goes to +Vcc or 5V in our case, and white would be the signal cable.

author
Dylan91 (author)2016-06-30

Nice work:) with the same procedure can i control a 4 BLDC? So can i build an arduino based quadrocopte? Someone said to me the arduino not "fast enough" for it.

author
MithilR (author)Dylan912016-07-01

You can control 4 BLDC motors. But the clock rate of arduino is less so even if you make one it won't be stable. I would recommend you go for a different controller with a faster clock rate.

author
Dylan91 (author)MithilR2016-07-02

Thank you for your fast response:)

author
Williamdapotato (author)2016-06-20

Hi there, Id like to know what you use to control it?

author
MithilR (author)Williamdapotato2016-06-21

In this circuit, it will rotate at a constant speed.It rotates at the speed given in the command esc_signal.write(55);

If you want to control it, you can connect a potential variable on the analog pins and map the value between 40-130 to change the speed.

author
AbhishekD77 (author)2016-06-19

Does the brushless motor EDC work with the same PWM signals as the servos ( 50 Hz with 1 to 2 milliseconds duty cycle ) ?

author
MithilR (author)AbhishekD772016-06-19

Yes, both servo motor and brushless motor driver (ESC) follow the same protocol.

author
ambardeep made it! (author)2016-06-04

I havent finished my project yet, but this made things soooo much easier. Thanks a ton! Now, I just have to finish the remaining 2 parts of my electric skateboard. Cheers!

IMG_20160604_235047.jpg
author
ahmet_024102 (author)2016-06-03

great project

About This Instructable

17,371views

185favorites

License:

Bio: A grad student at Boston University, I graduated with Computer Engineering degree and my area of interest is Robotics. I also have a heavy inclination ... More »
More by MithilR:Extendable handheld gimbal for GoPro/SJ4000/Xiaomi Yi/iLookInterfacing Brushless DC Motor (BLDC) with ArduinoHow to build a Quadcoptor. (NTM 28-30S 800kV 300W and Arducopter APM 2.6 & 6H GPS 3DR Radio and FlySky TH9X)
Add instructable to: