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() http://arduino.cc/de/Reference/ServoWrite
* or writeMicroseconds  http://arduino.cc/de/Reference/ServoWriteMicroseconds

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.

German: http://tom-620.bplaced.net/rc_modelle/zubehoer/regler/hobby_king/hk_80A_regler_deutsch.pdf
English: http://www.hobbyking.com/hobbyking/store/uploads/811103388X7478X20.pdf

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: http://1.bp.blogspot.com/-eqDaRgO5FjU/T9U3avwT2-I/AAAAAAAAALE/-8pj4qD12Q0/s1600/Figure2_2_edit.jpg

Step 3: Upload Sketch

Just copy and paste this Code to your IDE:

Coded by Marjan Olesch
Sketch from Insctructables.com
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: http://www.hobbyking.com/hobbyking/store/uploads/811103388X7478X20.pdf)

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.

Visit my Youtubechannel:   http://www.youtube.com/diiaf
<p>Here is my two cents. Should work for any ESC. You may need to play <br>with delay times. Choose your own speed as you wish, between HI and LO.</p><p>/*** ***/</p><p>#include &lt;Servo.h&gt;<br> <br>Servo esc;<br> <br>void setup()<br>{<br>esc.attach(9);<br>delay(5000);<br>esc.write(179); // HI<br>delay(5000);<br>esc.write(1); // LO<br>delay(5000);<br>esc.write(90); // MID<br>delay(10000);<br></p><p>esc.write(120); // SPEED<br></p><p>}<br> <br>void loop()<br>{<br>}</p>
<p>thanks for the tutorial really helpful ; </p><p>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 )</p>
<p>Thank you so much. this method works for my esc. Thankssssssss. hahahha</p>
<p>It works</p><p>. Damn it. I am damn happy. </p>
<p>Hi I've been trying to get my esc to work with a few different intro guides that i've found online, but the only thing that happens once I connect everything up with the motor and the battery as well is that it keeps beeping every couple of seconds and does not stop.</p><p>This is the hardware I'm using:</p><p>Turnigy Plush 40A ESC</p><p>Turnigy Aerodrive D3536/8 1000KV brushless outrunner motor</p><p>Zippy compact 4 cell 14.8V LiPo battery</p><p>- Sainsmart Arduino Nano (using D6 = pin 9, at least according to some google searches)</p><p>I've tried the above code, also starting with 700, 2000, and a few other numbers as well and nothing seems to work. Motor doesn't move at all, and as mentioned above just keeps beeping. Appreciate any help you might be able to provide. Thanks for your help.</p>
<p>Hello,</p><p>I have the same situation... just </p><p>beep .....beep.... beep every 2 seconds.</p><p>did you find the reason?</p><p>thanks.</p>
<p>hello, love this tutoral, and I'm using it to power 4 esc/motors.</p><p>I've pretty much just quadrupled your send routines:</p><p>firstESC.writeMicroseconds(value);</p><p>secondESC.writeMicroseconds(value);</p><p>thirdESC.writeMicroseconds(value);</p><p>fourthESC.writeMicroseconds(value);</p><p>Running the motors without props they run fine for as long as I need, but I put some small 6&quot; props on for testing, and after about 10 seconds at least one motor slows and stops. Eventually two go, then three.</p><p>I'm running 2300kva, I would have thought these motors could have handled it. </p><p>Is there something I'm missing?</p>
<p>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?</p>
<p>It turned out to be power supply, I was using the wrong sort. Stuck a LiPo on it and everything is good.</p><p>I forgot I posted this otherwise I would have updated it, thanks for the reply though.</p>
<p>Hi,</p><p>Nice post !</p><p>can i use Arduino Nano V3 instead of UNO ?</p><p>If yes, than how to do it ?</p><p>Thanks in advance !</p><p>Regards,</p><p>Vishal</p>
Hi thanks for this info. I have esc's that don't run prop; do you think by reprogramming them can fix the problem? Thanks.
<p>Hello Everyone, </p><p>I have been trying to bet my ESC running but no luck and no sound whatsoever :( </p><p>I am powering my Red Brick 60A ESC with a laptop battery (is this ok?). </p><p>Also my ESC appears to not have a BEC (no where does it say BEC). so I connected the arduino to the ESC like so:</p><p>white - pin9 arduino</p><p>red - 5V</p><p>black - GND</p><p>this is the last code I tested. Again, no sound. Very strange. I tested the voltage from the battery and from the arduino, and it is working..</p><p>Can anyone please point me in the right direction?</p><p>Thank you and have a great assemblable 2017 :P</p><p>#include &lt;Servo.h&gt;</p><p>int value = 0; // set values you need to zero</p><p>Servo firstESC;</p><p>const int ESC=9; // </p><p>void setup() {</p><p> firstESC.attach(9); // attached to pin 9 I just do this with 1 Servo</p><p> pinMode(ESC,OUTPUT);</p><p> Serial.begin(9600); // start serial at 9600 baud</p><p> Serial.println(&quot;starting arm....&quot;);</p><p> firstESC.writeMicroseconds(0);</p><p> delay(1000);</p><p> firstESC.writeMicroseconds(2000); </p><p> delay(1000);</p><p> firstESC.writeMicroseconds(700);</p><p> delay(1000);</p><p> Serial.println(&quot;fimarm...&quot;);</p><p>}</p><p>void loop() {</p><p> firstESC.writeMicroseconds(value); </p><p> if(Serial.available()){ </p><p> value = Serial.parseInt(); // Parse an Integer from Serial</p><p> Serial.print(&quot;typed&gt;&quot;+value);</p><p> }</p><p>}</p>
<p>Hello Everyone,</p><p>I have been trying everything to get my ESC to work. I have the following code..</p><p>I believe my ESC does not have BEC, it is a RedBrick 60A ESC.</p><p>I powered the ESC with a standard laptop type battery (in the picture).</p><p>I connected:</p><p>white - PIN9</p><p>red - 5V</p><p>black - GND</p><p>my ESC does not make any sounds.</p><p>Can anyone please help in finding out the problem? </p><p>Because no sound whatsoever :(</p><p>I measured the voltage and the battery powers the ESC and arduino also powers the red pin on the ESC.</p><p>This is one of the codes I tried.</p><p>#include &lt;Servo.h&gt;</p><p>int value = 0; // set values you need to zero</p><p>Servo firstESC;</p><p>const int ESC=9; // </p><p>void setup() {</p><p> firstESC.attach(9); // attached to pin 9 I just do this with 1 Servo</p><p> pinMode(ESC,OUTPUT);</p><p> Serial.begin(9600); // start serial at 9600 baud</p><p> Serial.println(&quot;starting arm....&quot;);</p><p> firstESC.writeMicroseconds(0);</p><p> delay(1000);</p><p> firstESC.writeMicroseconds(2000); </p><p> delay(1000);</p><p> firstESC.writeMicroseconds(700);</p><p> delay(1000);</p><p> Serial.println(&quot;fimarm...&quot;);</p><p>}</p><p>void loop() {</p><p> firstESC.writeMicroseconds(value); </p><p> if(Serial.available()){ </p><p> value = Serial.parseInt(); // Parse an Integer from Serial</p><p> Serial.print(&quot;got &gt;&quot;+value);</p><p> }</p><p>}</p>
<p>@SaurabhK45 Try this link: https://hobbyking.com/media/file/962315753X35454X22.pdf</p>
<p>The link doesn't work. It just says error 404 when the page goes to hobbyking. Is there another link?</p>
<p>Hi... great tutorial....! </p><p>I was just wondering, is it possible to download the english version of the instructions you posted? It seems that the link to the German version works fine but the link to the English version is broken :-( .......Thanks in advance</p><p>Source:<br> German: <a href="http://tom-620.bplaced.net/rc_modelle/zubehoer/regler/hobby_king/hk_80A_regler_deutsch.pdf" rel="nofollow"> http://tom-620.bplaced.net/rc_modelle/zubehoer/re...</a><br> English: <a href="http://www.hobbyking.com/hobbyking/store/uploads/811103388X7478X20.pdf" rel="nofollow"> http://www.hobbyking.com/hobbyking/store/uploads/...</a></p>
<p>what if i want to use the battery to power up the arduino? is there a coding that i could use?</p>
<p>excuse me, iam newbie. i need help how to calibrate ESC Seaking v3 120 Amp.</p>
<p>Found how to calibrate traxxas XL 2.5. Hope this helps:</p><p>#include &lt;Servo.h&gt; </p><p>#define MAX_SIGNAL 2300</p><p>#define NETRUAL 1400</p><p>#define MIN_SIGNAL 400</p><p>#define MOTOR_PIN 9</p><p>Servo motor;</p><p>void setup() { //open serial monitor</p><p> Serial.begin(9600);</p><p> Serial.println(&quot;Uno online. Software launch sucessful&quot;);</p><p> delay(100);</p><p> Serial.println(&quot;Calabration set for TRAXXAS XL 2.5. Please wait for further instruction.&quot;);</p><p> delay(100);</p><p> Serial.println(&quot;Begin calibration with ESC powered off and LiPo attached. Connect control wire and grnd to Arduino. Press any key when complete&quot;);</p><p> while (!Serial.available());</p><p> Serial.read();</p><p> motor.attach(MOTOR_PIN);</p><p> Serial.println(&quot;Output at NEUTRAL. Please press and hold ESC calibration button. Light shall flash green then red. Release the button&quot;);</p><p> delay(1000);</p><p> Serial.println(&quot;Wait for ESC to blink red once. Then press any key&quot;);</p><p> while (!Serial.available());</p><p> Serial.read();</p><p> Serial.println(&quot;Now outputting maximum output.&quot;);</p><p> motor.writeMicroseconds(MAX_SIGNAL);</p><p> delay(1000);</p><p> Serial.println(&quot;Wait for ESC to blink red twice. Then press any key&quot;);</p><p> while (!Serial.available());</p><p> Serial.read();</p><p> Serial.println(&quot;Sending minimum output&quot;);</p><p> motor.writeMicroseconds(MIN_SIGNAL);</p><p> delay(1000);</p><p> Serial.println(&quot;ESC should blink green once. If not, calbration has failed. Please atempt agian&quot;);</p><p>}</p><p>void loop() {</p><p>}</p>
<p>Worked perfectly!</p>
<p>for me it worked, after 4 beeps type 700 then 750, 800, 900 </p>
<p>Thanks! Worked great ..</p><p>For my HobbyKing 20A ESC, I had to:</p><p>- Upload the code in Arduino<br>- Write <strong>2000</strong> in the Serial window<br>- Wait for 4 beeps, then write <strong>700</strong><br>- Wait for the beeps to finish, then write <strong>750</strong><br>- Now write whatever speed you like (Min = <strong>755</strong>, Max = <strong>2000</strong>) .. Be careful when writing 2000! It moves like a monster</p>
<p>I have posted the comment below in other spaces, but I feel it is most appropriate here for some of the questions I have seen. Note: us = microSeconds.</p><p>My biggest question is why use the Servo.h lib? To get a motor turning at its full speed or RPMs requires it be given the correct voltage from the ESC (a different topic and I use a benchtop PS not batteries for this) and the proper pulse rate. The ESCs or at least simonk ESCs send these pulses to the motor based on the rate of data given it and length of the pulse. The maximum length of the pulse to send for maximum spin is 2000 us. The Servo.h sends a 2000 us pulse every 20000 us, 50 Hz or 50 times a second. I found that 490 Hz sends the fastest pulse of 2000 us. If you want to look at it in duty cycle, this is a close to a 99.0% duty cycle for 490 Hz. It is only a 10% duty cycle for 50 Hz. To get your motor to spin at its fastest RPM both the 2000 us pulse plus sending it as fast as possible is needed. Obviously there is a limit and 490 Hz is the limit. Any faster and you can't send a 2000 us burst. I have never tested it, but I have always wondered, if you lower the burst length and raise the Hertz what will that do to the speed of the motor.</p><p>Here is the code I use. I also have a serial GUI sliding bar interface that sends the same serial data - 0 thru 2000 - to the Arduino so I can control speed easily. I use this only for testing my motors on a bench.</p><p>//This code is for controlling a SimonK ESC.<br>//Made by Carl Davis <a href="mailto:carldavis114@comcast.net" rel="nofollow">carldavis114@comcast.net</a></p><p>int PinToESC = 3;</p><p>// You can enter the data by hand in a terminal window or build a GUI slider to control it via a terminal connection.<br>int data = 700; //Usually has the motor running when started<br>//Connect the GND pins of the Arduino and the ESC (Black).</p><p>void setup(){<br> pinMode(PinToESC, OUTPUT); //connect this PWM pin with the data cable of the ESC<br> analogWrite(PinToESC, data);<br> Serial.begin(115200);<br> while (!Serial) {<br> ;<br> }<br>}</p><p>void loop(){<br> if(Serial.available()){<br> data = Serial.parseInt(); // Parse an Integer from Serial<br> analogWrite(PinToESC, data);<br> }<br> //Serial.println(data);// Comment in if you want to see the data setting on the term window<br>}</p>
<p>Hi! I am wondering two different things.</p><p>1. Where did you find out that the ESC's can receive a signal between 700 and 2000 us(microseconds)</p><p>2. Why do you have the data value from 700 to 2000? The arduino site for the analogWrite function(https://www.arduino.cc/en/Reference/AnalogWrite) indicates that it only takes values from 0 to 255. What would sending 700 do?</p>
Question 2 first. You are looking at analogWrite which is set at a specific PWM frequency - about 500 HZ. With analogWrite you use an 8 bit scale (0 - 255) as input.<br>The (700 - 2000) argument I was referring to in my post was talking about the Servo lib function writeMicroseconds.<br><br>It runs at about 50 Hz and takes a microsecond parameter.<br>Servo example<br>#include .<br>Servo ESC;<br>ESC.attach(Pin you are sending data thru);<br>ESC.writeMicroseconds(700);<br>ESC.writeMicroseconds(1000); //Increase speed<br><br>Servo is not usually used to run a BLDC so I see the confusion. It was a concoction I tried, using someones posting, as I was try to understand BLDC motors. In my post I was questioning why use the Servo lib, which is where the arguments of 700 to 2000 I talked about were used.<br><br>To answer question 1. that is the limitation of Servo.h lib not ESCs. Sorry if I implied that. I am working on another lib to try and find out the top and bottom end of a PWM signal to ESC and figure out what is the best frequency to use. This is taking me down the road of ESC and motor control design. I am no where near finished as I do this in spare time.
<p>Thanks for the help! That was very helpful! </p>
<p>If you are interested I have made this program to change and save the settings of ESC :<br><a href="https://www.youtube.com/watch?v=hyIqT0kAdVo&feature=youtu.be" rel="nofollow">https://www.youtube.com/watch?v=hyIqT0kAdVo&amp;feature=youtu.be</a></p>
<p>Hi, just starting out with this and I would like to confirm that my motor is being under powered.... is so any ideas why...</p><p>so i have a Sunnysky x2212-13 9800ii motor and a WST blheli20A esc, the esc can handle 2-4s lipo. i am powering the esc with a power supply set to 14.8v. </p><p>so with your provided code the motor starts up correctly and runs within the mapped ranges of 0 and 179. but when the motor is running at its highest range right before the esc turns the motor off because it is out of range (***guess...) the motor is only pulling .6 amps. which falls quite short of the manufactures spec sheet of 14.9 amps @14.8v. is this normal operation or is it not reaching its full potential. i have put a prop on it and it does have some pull but i was kinda expecting more......</p><p>Thanks in advance for any help</p>
<p>I wanted to ask if an Arduino board can control ANY ESC?</p>
<p>Hi, I am new in this world of ESC's and I am just in the middle of doing my own electric longboard and I would like to know if an ESC is able to generate negative PWM so the motor can run in the opposite direction. I imagine this is the way to make a motor brake so it can generate negative torque and so on make me stop or even go backwards if I ever need to.</p><p>Thank you very much, any help will be really appreciated </p>
<p>hey i have calibrated all(4) ESC ( EMAX SimonK series ESC, 20 A) through RF Avionic RCB6i (2.4Ghz 6ch transmitter with receiver) but when i pickup the throttle one motor is running slower than other. Should i have to try the above procedure?? </p><p><a href="http://abc-rc.pl/templates/images/files/995/1414510420-emax-user-instruction-for-simonk-series-esc.pdf" rel="nofollow">http://abc-rc.pl/templates/images/files/995/141451...</a></p><p>plz reply ASAP</p>
<p>ESC's normally receive a continuous signal, they are running a different rates because each motor is slightly different, each resistance slightly different, and these small differences add up to a speed difference. If it's an input problem, make sure the ranges of input are all the same IE 700-2000, 1200-1800, etc. </p>
<p>I have a issue</p><p>I calibrate my ESC's (4) but two of them have begin to work with the value 1200 to 2000 and the others with value between 700-2000</p><p>Why does not work with the same value when i calibrate the minimu 700 and the maximun 2000</p>
<p>Anybody know what the Signal is for the 120A version? (HK-1-8-120A). I've played around with this and can verify that it is accepting values well over 2k</p>
<p>I&acute;ve tried every option available here, in other sources and my own combinations, and I&acute;m still unable to make it fly. With degrees or microseconds, defining ratings from 40 to 150 or 700 to 2000. The motors start, accelerate with a variable in a ++ loop and suddenly always stop. Any advice?</p>
<p>if anyone knows how to start esc of 18A for brushless dc motor without using header file &quot;Servo.h&quot;. Then please help me??</p>
<p>I tried your code and ESC gave the calibration confirmation but motor didn't run. </p><p>My procedure is-</p><p>1- First send the maximum signal to arduino.</p><p>2- turn on the ESC</p><p>3- after right beep i sent the minimum signal to ESC and ESC made some beeps and gave a calibration confirmation tone. but now i am giving the singal between maximum and minimum, motors are not rotating.</p>
<p>Hey All. I run this Code:</p><p>#include &lt;Servo.h&gt;</p><p>#define MAX_SIGNAL 2000<br>#define MIN_SIGNAL 700<br>#define MOTOR_PIN 9</p><p>Servo motor;</p><p>void setup() {<br> Serial.begin(9600);<br> Serial.println(&quot;Program begin...&quot;);<br> Serial.println(&quot;This program will calibrate the ESC.&quot;);</p><p> motor.attach(MOTOR_PIN);</p><p> Serial.println(&quot;Now writing maximum output.&quot;);<br> Serial.println(&quot;Turn on power source, then wait 2 seconds and press any key.&quot;);<br> motor.writeMicroseconds(MAX_SIGNAL);</p><p> // Wait for input<br> while (!Serial.available());<br> Serial.read();</p><p> // Send min output<br> Serial.println(&quot;Sending minimum output&quot;);<br> motor.writeMicroseconds(MIN_SIGNAL);<br> Serial.println(&quot;Done&quot;);<br>}</p><p>void loop() { </p><p>}</p>
<p>Thank you for this example. I just cant find one thing, quote: &quot;</p><p>The Hobbyking ESC's can receive a Signal between 700 and 2000 us(microseconds).&quot; </p><p>I'm looking in the manual. But I can't find it. Can you help me? Thank you very much.</p>
<p>I have tested this with a Arduino Nano MCU and a Turnigy ESC and it works like a dream.</p>
<p>Could you please share the arming sequence for the Hobbyking ESC? Thanks!</p>
<p>The Arming Sequence seems to be <br>individual, because you can make different settings on the ESC. My <br>arming sequence on standard settings is: <br></p><p>void setup()<br>{<br> Serial.begin(9600); <br> myservo.attach(10);<br> delay(1);<br> myservo2.attach(11);<br> delay(1);<br> myservo3.attach(12);<br><br> myservo.write(40);<br> myservo2.write(40);<br> myservo3.write(40);<br> delay(1000);<br> myservo.write(60);<br> myservo2.write(60);<br> myservo3.write(60);<br> delay(1000);<br> myservo.write(40);<br> myservo2.write(40);<br> myservo3.write(40);<br> delay(1000);<br>}</p>

About This Instructable




More by maole_95:~10-15kV Tazer / High Voltage Multiplier 3-LED Backlight: Xamarin and Arduino with HC05 ESC Programming on Arduino (Hobbyking ESC) 
Add instructable to: