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.

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.

<p>Can we vary the speed of the motor with arduino itself? Or we need to add any component to do so?</p>
<p>You can vary the speed by the changing the value in this command.</p><p>esc_signal.write(<strong>55</strong>); </p><p>Vary this value between 40-130 to change the speed of motor from minimum to maximum.</p><p>No extra hardware required except the ones mentioned in this instructable.<br></p>
<p>Umm.... I have another question.<br><br>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? <br><br>How to do it the either way? <br><br>I want to keep the arduino connected to my computer and then change the coding that is motor speed variation at my requirement. <br><br>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.</p>
<p>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.</p>
<p>The board can be supplied with external power from the DC power jack (<strong>7 - 12V</strong>). 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.</p>
<p>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.</p><p>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?</p>
<p>Yes to the first paragraph of concerns/questions.</p><p>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.</p>
<p>Good job. Got the program too. Thank you!</p>
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?
Look into interfacing the mindwave with an Arduino. From there its the same as mentioned in the tutorial.
<p>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?</p>
<p>Yes. That will work.</p>
<p>My ESC has a black, red and white wires witch ones should I connect where on the UNO?</p>
<p>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.</p>
<p>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 &quot;fast enough&quot; for it.</p>
<p>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.</p>
Thank you for your fast response:)
<p>Hi there, Id like to know what you use to control it?</p>
<p>In this circuit, it will rotate at a constant speed.It rotates at the speed given in the command esc_signal.write(55);</p><p>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.</p>
<p>Does the brushless motor EDC work with the same PWM signals as the servos ( 50 Hz with 1 to 2 milliseconds duty cycle ) ?</p>
<p>Yes, both servo motor and brushless motor driver (ESC) follow the same protocol.</p>
<p>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!</p>
<p>great project</p>

About This Instructable




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/iLook Interfacing Brushless DC Motor (BLDC) with Arduino How to build a Quadcoptor. (NTM 28-30S 800kV 300W and Arducopter APM 2.6 & 6H GPS 3DR Radio and FlySky TH9X) 
Add instructable to: