Controlling A Brushless Motor

I bought a brushless motor, a brushless motor controller and a li-po battery.

The motor controller has 3 wires (white, red and black), can these be connected to the arduino deicimila to control the motor?

If so, what pins and how do I control it? I don't see an applicable library/example for it.

Mine has a white wire instead of the yellow shown in the image.

The three thin wires with the servo connecter should be connected to the arduino as if it was a servo. The white wire is the signal that connects to the Arduino output pin. The blck wire should be connected to ground. The center wire has +5 volts and should not be connected to the arduino (unless you want to use this to provide the +5 volts to power the arduino)

The three thick wires are connected to the motor. (you can reverse any two of these wires if the motor turns in the wrong direction). The two thick wires connect to the battery.

Use one of the Arduino servo libraries to drive the controller. Most need arming by sending a minimum throttle signal. Check the instructions that came with the controller to find out what pulse width this is.

pretty sure those controllers use a servo signal to controll them. try using the hardware servo library and treating them like a servo. looks like the white is the signal (connect to digital pin) the black is ground, and the red is +5 volts.

(be carefull, i've never personally used one of those controllers)

thnx for the responses but i still have questions (i will solder everything tomorrow and then try to control the motor).

unfortunatelyi don’t have instructions for the controller, the only info i have for it is at the bottom of this post.

where does pulse width come into play in the servo examples? (i.e. does myservo.write work like analogWrite except that it is pre-tweaked for degrees?)

will this code work (assuming i don’t have a problem with arming)?: is a delay necessary (if no delay is used, will it just automatically delay the 2ms period of the PWM signal?)? is a minimum throttle signal necessary previous to this code or will the fact that this code ramps up make that unecessary?

int ESCpin = 11;    // ESC signal wire connected to pin 11 on arduino
int val = 0;        //variable to store PWM value
void setup() 
void loop() 
  for(val = 0; val <= 255; val += 5)
    analogWrite(ESCpin, val);

Manufacturer’s descriptions:
·Input Volt: 6V-12V
·Constant Current: 30A
·Max Current: 40A
·Low-Voltage Cutoff: Auto detect and set
·Size: 5524.55.3mm
·Weight:22g(Net Weight)
·Hight rate PWM
·Low resistence
·Sisteen cells Max (with BEC disabled)
·User programmable brake
·Low voltage auto setting based on battery
·Throttle range self-adjusting
·Soft start ramp up
·Auto motor cutoff with reset
·Runs motor in forward or reverse
·Safe power arming program ensures motor will not run accidentally after turn on
·Low torque start
·Auto shut down when signal is lost

you should not try to use your speed controller with that sketch!

Servo signals are not the same as PWM. Although they are sometimes confusingly called PWM, servo signals are actually PPM (pulse position modulation). In the servo code, altering the degrees varies the width of the HIGH pulse from approx 1ms to 2ms. But unlike PWM, the LOW pulse is always around 20ms long.

If you are using Arduino version 0012, there is a servo library that comes with that. You could try it with the example knob.pde sketch that uses a potentiometer to adjust the pulse width. But any library and sketch that is intended for a servo should work. You will need to expirement to see if the speed controller arms at 0 degrees or 180 degrees. Once armed (you should hear some beeps if the controller is connected to the motor) , varying the number of degrees should change the speed of the motor.

Good luck!

here's an update as i mess around with it more and maybe i'll get some more tips/info as i am in the process of trying stuff out.

i ran the servo sweep sketch and it took a while but then the motor kicked in and sped up (wow its fast, was holding it in my hand), then it slowed down to a stop (was too busy trying to turn it off to know for sure if its speed tapered to a stop) and i turned it off after it repeated the process a second time.

i then tried just going at "int pos = 0" and i got 3 beeps and a few jiggles but nothing happened. i did the same with "int pos = 180" with the same results, same with 90. which i guess means it doesn't arm at any of those values.

thnx for the responses so far mem, it has helped a lot, makes me happy that i bought the arduino due to the help i get on the forum and website.

i just finished making a motor mount with a 25pack cd storage container. filled it with golf balls, mounted the motor with a couple rubber dampeners and i have some rubber feet on the bottom. not gunna hold that thing in my hand ever again, it wanted to rip free... it was pretty awesome. :)

ok i think i got this figured out. here’s my sketch to keep the motor running continously and at the lowest speed possible.

#include <Servo.h> 
Servo myservo;
int pos = 0;
void setup() 
void loop() 
  if(pos <= 30)
    for(pos = 0; pos < 40; pos += 5)
    int pos = 31;

here’s what i figured out (i think):

  1. it arms at position 0 (well apparently anything under 30, but i’ll have to see if it takes less than 5 seconds if i set position to 0 for a period of time)
  2. the minimum position is 30, having pos = 25 rarely worked and less than that never worked
    3)it takes 5 seconds to arm (it won’t run at all if given less than 5 seconds to reach position 30)

i am interested in making a library for brushless motors. got lots to learn about brushless motors, ESCs and the best way to interact with them though. will save others time and confusion though.

Hi there

im also trying to controll a motor, but Im using a Digital Speed Controll made by Hitec, it is an SP 1801n:

I have adapted a version of the servo sweep program with pretty crappy results but i got it turning. (too fast for my liking)

I tried your program but i got nothing out of it.
Do you know what I can change in your parameters to get something happening, What numbers do what in your program?



here is my post:

here is my prog:

int servoPin = 7; // R/C Servo connected to digital pin
int mySpeed; // angle of the servo (roughly in degrees) 0-180
int pulseWidth; // function variable

void servoPulse(int servoPin, int myAngle) {
pulseWidth = (mySpeed * 11) + 500; // converts angle to microseconds
digitalWrite(servoPin, HIGH); // set servo high
delayMicroseconds(pulseWidth); // wait a very small amount
digitalWrite(servoPin, LOW); // set servo low
delay(20); // refresh cycle of typical servos (20 ms)

void setup() {
pinMode(servoPin, OUTPUT); // set servoPin pin as output

void loop() {
// cycle through every angle (rotate the servo 180 slowly)
for (mySpeed=110; mySpeed<=118; mySpeed++) {
servoPulse(servoPin, mySpeed);

I've used several models of brushless speed controllers in R/C electric planes over the last few years. They are very reliable and powerful controllers, avalible in all kinds of maximum current & voltage ratings. They can run a little hot and normally one mounts them in a plane such that they can receive a little air flow for cooling.

You can treat them just like a servo, however most do have a few safety features, such as disabled at power up and wait until servo command is moved to 'zero poition', this prevents the motor starting at first turn off. Also it senses battery voltage and when low either cuts off the motor or pulses the motor on and off to allow time for a safe landing.

Here is a great site with a section on R/C electronics

The ESC needs to arm before it will drive the motor. Typically an ESC will arm when it gets minimum throttle setting for a second or so. But some controllers are programmable or self adapt to the transmitter so you need to read the instructions for your ESC.

Lazer’s code arms his ESC because it starts by sending a minimum pulse width for 1 second.

I would recommend that code to drive an ESC had a specific function for arming. Here is an example, this may need to be modified for ESC that need longer arm times or different pulse widths. And its not tested so let me know if it works for you :wink:

// this uses the Arduino servo library included with version 0012 

// caution, this code sweeps the motor up to maximum speed !
// make sure the motor is mounted securily before running.

#include <Servo.h> 

Servo myservo;

void arm(){
  // arm the speed controller, modify as necessary for your ESC  
  delay(1000); //delay 1 second,  some speed controllers may need longer

void setSpeed(int speed){
  // speed is from 0 to 100 where 0 is off and 100 is maximum speed
  //the following maps speed values of 0-100 to angles from 0-180,
  // some speed controllers may need different values, see the ESC instructions
  int angle = map(speed, 0, 100, 0, 180);

void setup()

void loop()
  int speed;

  // sweep up from 0 to to maximum speed in 20 seconds
  for(speed = 0; speed <= 100; speed += 5) {
  // sweep back down to 0 speed.
  for(speed = 95; speed > 0; speed -= 5) {
  delay(5000); // stop the motor for 5 seconds


I wanted to control a Brushless Motor with my arduino. So I connected my ESC to the motor (3 cable from motor to 3 output cable from the ESC), the ESC ground to arduinos ground (black), the signal line (white) to an arduino output pin. I didn't connect the red 5+ from ESC.

When connected the the ESC to a LIPO (red on red, balck on black), the ESC beeped, the motor didn't move.

To far so good, as my pules were at 900mycros, which should be the base (motor off) value. As I increased the pulse signal slightly (with a pot.) the motor began to move. But after a few seconds my (borrowed) esc started to burn.

My friend told me that he had used this esc with this motor, so i guess the esc should been strong enough.

Has anyone an idea what went wrong? Did I connect the esc correctly to the arduino? Can you burn the esc by sending weird pulses? thanx, tobias

i might be way off, or i might be on topic, but:

i have seen lots of references to using the h bridge setup to control dc motors...

is using an ESC essentially like replacing the whole h bridge setup?

Electronic Speed Controllers for brushed DC motors are implemented using an internal H-bridge. Radio Control ESC usually have additional features like arming protection and of course they are controlled by PPM signal from an RC receiver rather than the analogWrite form of PWM.

Using an ESC can be an easy way to control a DC motor but make sure you use the correct ESC for your motor.

hello everyone, i came across this post as i also wanted to power my brushless motors. using the code which mem posted i have managed to do this.

one thing i am having trouble whit is powering 4 at once? as i am building a quad helicopter so i need to power all 4.

any help with this will be most appreciated :)

The servo library distributed with Arduino only drives two servos. The code in this thread drives up to 8:

Does anyone know roughly the kind of response time brushless R/C ESC controllers offer? Are we looking at a few ms response after receiving a change in PPM signal or a few hundred ms? I am looking at these brushless ESC controllers to be used in a motor control stabilization feedback loop. If response time is slow, stabilization would not feel as solid. Just curious if anyone else experience this issue

Well the standard R/C servo type signal used to command ESC is based on a 20 msec update standard so the response should not be expected to be faster then that. How much slower I can't say and I'm not sure that would be a spec normally published in a ESC data sheet. I would think the size of the motor and the external load would also effect the response time from one 'setpoint' value to a new 'setpoint' value and of course the percentage change asked for.

Interesting question but I'm not sure there is a easy way to determine short of some experimentation.


This thread has a discussion on using i2c/TWI to interface with a speed controller and has some information that you may find relevant:

I am trying to use the Arduino Diecimila to control 4 DC motors at once, independent of each other. I would like to use an ESC however, the motors that I have only have a positive and a ground wire, is there any way to still use an ESC?

I am trying to use the Arduino Diecimila to control 4 DC motors at once, independent of each other. I would like to use an ESC however, the motors that I have only have a positive and a ground wire, is there any way to still use an ESC?

You are going to want a brushed-motor ESC (if you can find one), not a brushless motor ESC. The difference is the number of wires from the controller to the motor; brushed-motors use two wires (standard DC), brushless-motors use three (3-phase AC). You can’t interchange them.

You are going to find it difficult finding RC brushed-motor ESCs - it seems like nearly everything has gone over to brushless motors (for good reason - lower power usage coupled with higher torque, usually; just what modelers want) in the RC realm.

If you want to or need to use standard DC (brushed) motors, look into robot motor controller h-bridge drivers; there are plenty out there available from tons of places and makers, in numerous sizes (for controlling small < 1A motors to larger controllers for electric cars and the like, and everything in-between).

Another option, of course, is to build your own h-bridge controller circuit for each motor, and run those off of the digital or PWM pins.