ESC Programming on Arduino (Hobbyking ESC)




Introduction: ESC Programming on Arduino (Hobbyking ESC)

Hello Community,

I'm going to show you, how to program and use the Hobbyking ESC. I just found a few information and tutorials, which really didn't help me very much, so i decided to program an own sketch, which is very simple to understand.

Important to know:

* ESC means Electronic Speed control
* The ESC has a 5v(not used), GND and Signal Pin like a Servo
* You control it like a Servo with  write()
* or writeMicroseconds

In my Example i use writeMicroseconds, because it is easier to understand.
So let's go...

Step 1: Getting ESC Information

You really should remark the Amperevalue of your ESC. This tutorial is only tested on 20 AMP ESC :

I can't really promise, that this is working with an other ESC but i think so, because in the english manual are 20 and 30 Amp ESC's described. In the German version is a generalisation from 10 to 120 Amp, thats why I think this could work for every ESC.


Step 2: Connection to Arduino

I tried it with an arduino uno R3. I think it's also possible with an e.g. arduino Duemilanove or Mega.

First you have to connect the ESC to you lipo or NiMH. When you have done that you connect the ESC like so:

*  Black to GND
* White/Yellow to PIN 9

Because you connected the ESC to your battery, the ESC is put under voltage. Thats why it It is important, that you DON'T connect the red wire to your 5v Port, because it could destroy your computer's USB Port.

On this picture you can see the correct connection between ESC and Arduino (Mega).

Picture source:

Step 3: Upload Sketch

Just copy and paste this Code to your IDE:

Coded by Marjan Olesch
Sketch from
Open source - do what you want with this code!
#include <Servo.h>

int value = 0; // set values you need to zero

Servo firstESC, secondESC; //Create as much as Servoobject you want. You can controll 2 or more Servos at the same time

void setup() {

  firstESC.attach(9);    // attached to pin 9 I just do this with 1 Servo
  Serial.begin(9600);    // start serial at 9600 baud


void loop() {

//First connect your ESC WITHOUT Arming. Then Open Serial and follo Instructions
    value = Serial.parseInt();    // Parse an Integer from Serial


Step 4: Understanding and Programming an ESC

ESC are programable like IC's or even your Arduino. You just don't have a language to program, but a menu made of sounds.

To come in this menu, which runs infinite btw you just have to do following Steps:

* Connect your ESC
* Configure the code (as much as ESC's you have and Pin-configuration)
* You should hear nothing, because the Arduino sends a zero
* Open your Serial Monitor and send '2000'. it means the highest Signal the ESC can receive
* You will hear the sounds which are described on the picture ( Source: Manual:

The Hobbyking ESC's can receive a Signal between 700 and 2000 us(microseconds). 700 means throttle at lowest position and 2000 on the highest Position. If you want to know what exactly you du, when you pick a menu visit the manual.

- Write 2000 us
- Wait until D-D-D-D to chose lipo as batterytype
- When it apperas, write at the third 'D' 700 in your Serial ( short delay, thats why you have to send it at the third 'D')
- ESC will make a sound, and the Option is chosed.

I Hope i could help you with this tutorial.



  • Tiny Home Contest

    Tiny Home Contest
  • Water Contest

    Water Contest
  • Metalworking Contest

    Metalworking Contest

51 Discussions

I was using the github code and it was working fine, but only for pin 9 and 10 on the arduino NANO the other pins that do have pwm do not work. Someone said it might be that pin 9 and 10 run on 980 hertz and the other pins only at 490 hertz. Is that the case and is it fixable?

Oh thanks for explained.

In my case, my pwm output from pid calculation is responsive but when it write to esc ,the bldc response is slow(its like have some delay on it) so my quad can't stable in any pid constants that i tune..

Please help how to make my esc reponse fast according to yaw and pitch angle with no delay ?( thanks.

hello, love this tutoral, and I'm using it to power 4 esc/motors.

I've pretty much just quadrupled your send routines:





Running the motors without props they run fine for as long as I need, but I put some small 6" props on for testing, and after about 10 seconds at least one motor slows and stops. Eventually two go, then three.

I'm running 2300kva, I would have thought these motors could have handled it.

Is there something I'm missing?

6 replies

Did you check the max amperage your ESC can provide vs the rating for the engine? Are your engines overheating because of too much power?

Sorry I honestly didnt see this reply.

It was just the power supplies I was using couldnt give amps fast enough. I eventually just bought a large capacity lipo and charger off ebay.

Thanks for the reply.

No worries, thanks for getting back to me :-)
LiPo will also be the long term solution, but for now, using a power supply for the algorythm tests with my students..
Thanks again for the the ESC instructions, they were very useful!

It turned out to be power supply, I was using the wrong sort. Stuck a LiPo on it and everything is good.

I forgot I posted this otherwise I would have updated it, thanks for the reply though.

hmm this was a while ago now.

I was using a pc power supply, but I couldnt get the motors to run at full speed for long before they eventually cause the power supply to fail.

I eventually just bought a proper lipo and charger off ebay, I think I got change out of $50 for both. I havent done much on this for a year or so because I've moved and no longer have the space, but I need to get bigger motors. The ones I have ALMOST lift it off the ground but the airframe is just under 1.4kg. I am also trying to lighten the load.


Question 6 months ago

Hello, is that all kind of ESC have the same signal value between 700 and 2000?

The link doesn't work. It just says error 404 when the page goes to hobbyking. Is there another link?

1 reply

I know this is very late but for any new people coming here, I found the link here

Found how to calibrate traxxas XL 2.5. Hope this helps:

#include <Servo.h>

#define MAX_SIGNAL 2300

#define NETRUAL 1400

#define MIN_SIGNAL 400

#define MOTOR_PIN 9

Servo motor;

void setup() { //open serial monitor


Serial.println("Uno online. Software launch sucessful");


Serial.println("Calabration set for TRAXXAS XL 2.5. Please wait for further instruction.");


Serial.println("Begin calibration with ESC powered off and LiPo attached. Connect control wire and grnd to Arduino. Press any key when complete");

while (!Serial.available());;


Serial.println("Output at NEUTRAL. Please press and hold ESC calibration button. Light shall flash green then red. Release the button");


Serial.println("Wait for ESC to blink red once. Then press any key");

while (!Serial.available());;

Serial.println("Now outputting maximum output.");



Serial.println("Wait for ESC to blink red twice. Then press any key");

while (!Serial.available());;

Serial.println("Sending minimum output");



Serial.println("ESC should blink green once. If not, calbration has failed. Please atempt agian");


void loop() {


2 replies

I tried it on my XL5 esc but it didn't work. Could you please tell me if there are any modifications I'd have to make to the code? Thanks!

Here is my two cents. Should work for any ESC. You may need to play
with delay times. Choose your own speed as you wish, between HI and LO.

/*** ***/

#include <Servo.h>

Servo esc;

void setup()
esc.write(179); // HI
esc.write(1); // LO
esc.write(90); // MID

esc.write(120); // SPEED


void loop()

thanks for the tutorial really helpful ;

working on ESC ( hobbywings 20A skywalker ) , you have to first calibrate the throttle range : set arduino to 1800 (the max for this esc ) you'll hear 2 beeps set the arduino to 1300 (min ) you'll hear 3 beeps and one long beep (you 're done now ) set the arduino to any value( 1300 -1800) the motor should be spinning now , next time just set it to 1300 before starting ( no need for calibration )

1 reply

Thank you so much. this method works for my esc. Thankssssssss. hahahha