Components · 10 min read

Brushless Motor Arduino ESC: Wiring, Arming and Calibration

Drive a brushless motor with Arduino and an ESC: wiring, arming, throttle calibration, Servo library code, KV, LiPo and prop table, BEC power and ESP32 LEDC.

To run a brushless motor with Arduino, you don't wire the motor to the pins; you put an ESC (Electronic Speed Controller) in between. The Arduino sends the ESC exactly the same signal it would send a servo, pulses of 1000–2000 microseconds repeated every 20 milliseconds, and the ESC distributes the tens of amps it draws from the LiPo battery across the motor's three phases to spin it at the speed you ask for. So whether you are building a drone, an RC plane, an airboat or a powerful fan, the code is only a few lines with the familiar Servo library.

The part that needs real care is not the code but the hardware and safety: the arming signal the ESC expects at power-up, the calibration that teaches it the throttle range, choosing the right battery and propeller for the motor's KV, powering the Arduino from the ESC's BEC, and testing without a propeller. This guide covers all of it in order, with numbers and calculations, and gives you working code for Arduino Uno, ESP32 (LEDC) and Raspberry Pi Pico.

What is a brushless (BLDC) motor and how does it work?

In a brushless DC motor (BLDC) the magnets are on the spinning part and the coils on the stationary part. There are no brushes or commutator to reverse the current mechanically, as in a brushed motor; that job, commutation, is done electronically by the ESC. Most drone and plane motors are outrunners: the outer can spins together with the magnets while the windings stay fixed inside. Numbers such as 2212 or 2205 give the stator size: a 2212 motor has a stator 22 mm wide and 12 mm tall. With no brushes rubbing, these motors are more efficient, quieter and longer-lasting, but they cannot run when simply connected to a battery.

FeatureBrushed DC motorBrushless (BLDC) motor
CommutationMechanical, brushes and commutatorElectronic, by the ESC
Wires23 (phases)
EfficiencyAbout 60–75%About 80–90%
Lifetime and maintenanceBrushes wear outNo wearing parts except the bearings
Driven byTransistor, MOSFET or L298NESC (or a 3-phase driver)
Typical useToys, robot cars, pumpsDrones, RC planes, airboats, fans

What is an ESC and why do you need one?

An ESC is a driver board with a small microcontroller and six power MOSFETs (three half bridges). It energizes the motor's three phases in turn and, by measuring the voltage induced in the floating phase while the motor spins (back-EMF), works out where the rotor is; that is how it runs sensorless motors smoothly. An Arduino pin can supply 20–40 mA at most, while a small drone motor draws 10–20 A: you need a circuit that can carry that current and switch the phases at the right moment, and that circuit is the ESC. The nice part is that the ESC takes its speed command just like a servo: a 1000 µs pulse means zero throttle and a 2000 µs pulse means full throttle.

ESC wireConnects toNote
Thick red and blackLiPo battery (+ and −)Usually an XT60 or T (Deans) connector
3 thick wires (color doesn't matter)The motor's 3 phase wiresSwapping any two reverses the direction
Thin white or yellowArduino signal pinServo signal, 50 Hz
Thin redBEC 5 V outputCan power the Arduino; dead on OPTO ESCs
Thin black or brownArduino GNDAlways connect it for a common ground

KV rating, LiPo cell count and propeller choice

A motor's KV rating tells you how many RPM it turns per volt with no load (here KV is not kilovolts but RPM per volt). A 1000 KV motor on a 3S LiPo (11.1 V) spins at roughly 1000 × 11.1 = 11,100 RPM unloaded; with a propeller fitted, the load pulls that down by 15–25%. Low-KV motors turn big propellers slowly and with torque, high-KV motors turn small propellers very fast. Putting a big propeller on a high-KV motor burns out both the motor and the ESC through overcurrent, so stick to the propeller and battery recommended in the manufacturer's thrust table.

LiPoNominal voltageFully chargedLower limit (under load)
1S3.7 V4.2 V3.3 V
2S7.4 V8.4 V6.6 V
3S11.1 V12.6 V9.9 V
4S14.8 V16.8 V13.2 V
KV rangeTypical propellerLiPoTypical use
700–1000 KV10–12 in (1045, 1147)3S–4SF450 / S500 quadcopters, slow planes
1000–1400 KV8–10 in (8045, 1047)3STrainer planes, A2212 airboat
1800–2600 KV5–7 in3S–4SFast planes, 5-inch FPV drones (2205–2207 motors)
3000 KV and up2–4 in2S–4SSmall FPV drones, ducted fans (EDF)

Choose the ESC by the motor's maximum current and leave at least 20–30% headroom: for a motor that pulls 18 A at full throttle, a 25–30 A ESC is a good fit. On the battery side, capacity multiplied by the C rating tells you how much current it can safely deliver: a 2200 mAh 25C LiPo gives 2.2 A × 25 = 55 A, plenty for a single motor. To estimate how long the battery will last, use the Battery life calculator; a motor averaging 10 A drains a 2200 mAh pack, using 80% of it, in about 10 minutes.

What is a BEC? Powering the Arduino from the ESC

Most ESCs contain a small 5 V regulator called a BEC (Battery Eliminator Circuit), and that voltage comes out on the middle red wire of the servo lead. In RC models it powers the receiver and servos without a separate battery; in an Arduino project it is the easiest way to run the board from the main battery. Linear BECs usually supply 1–2 A, switching ones (SBEC/UBEC) 2–5 A. If you connect the red wire to the Arduino Uno's 5V pin and the black one to GND, the Arduino runs straight from 5 V, bypassing its onboard regulator. ESCs labeled "OPTO" have no BEC; in that case power the Arduino from a separate 5 V supply or an LM2596 buck converter.

While the Arduino is plugged into your computer over USB, do not connect the BEC's red wire to the 5V pin: two 5 V sources end up tied together and current can flow back into the USB port. During testing, connect only signal and GND and tape the red wire off. Never skip the GND wire, though: without a common ground the ESC can't read the signal and the motor behaves erratically.

Wiring diagram: Arduino Uno, ESP32 and Raspberry Pi Pico

ConnectionArduino UnoESP32Raspberry Pi Pico
ESC signal (white/yellow)D9GPIO 13GP15
ESC GND (black/brown)GNDGNDGND
ESC BEC 5 V (red)5V (USB unplugged)VIN (USB unplugged)VSYS (USB unplugged)
Potentiometer wiperA0GPIO 34GP26 (ADC0)
Potentiometer outer pins5V and GND3V3 and GND3V3 and GND
ESC power leadsLiPo batteryLiPo batteryLiPo battery
ESC motor leadsMotor's 3 phasesMotor's 3 phasesMotor's 3 phases
Do every test without the propeller. A 10-inch prop on a 1000 KV motor can badly injure a finger if a code bug or the calibration sends the motor to full throttle unexpectedly. Screw the motor to a solid board, plug the battery in last and always unplug it first.

Arming: bringing the ESC online safely

An ESC does not start spinning the motor the moment you connect the battery. It first plays a short start-up tune, reports the battery's cell count with beeps and then waits to see zero throttle (about 1000 µs) on the signal line. Once it sees throttle held at zero for 1–2 seconds it gives a long beep and is ready for commands; this is called arming. The safety feature stops the motor from leaping to full power if you plug in the battery with the throttle stick up. On the Arduino side, all you need to do is send 1000 µs as the very first thing in setup() and wait a few seconds.

BeepUsual meaning
Short tune at power-upThe ESC has power and passed its self-test
One short beep per cell (3 for 3S)Battery voltage detected
One long beepZero throttle detected, ESC armed
Beep repeating every few secondsNo signal, or throttle not at zero
Two short beeps when powered at full throttleCalibration mode: storing maximum throttle

Throttle calibration step by step

Calibration teaches the ESC the minimum and maximum pulse widths your Arduino sends. Skip it and the motor may start with the pot halfway up or never reach full speed. You do it once per ESC, and the ESC keeps the setting in its memory.

  1. Remove the propeller, disconnect the battery from the ESC and upload the calibration sketch below to the Arduino.
  2. Open the Serial Monitor at 9600 baud; meanwhile the Arduino is sending full throttle (2000 µs) to the ESC.
  3. Connect the battery to the ESC. After its start-up tune the ESC gives two short beeps to confirm it has stored the maximum.
  4. As soon as you hear the two beeps, type any letter in the Serial Monitor and press Enter; the Arduino drops the throttle to 1000 µs. If you wait too long, most ESCs enter programming mode after a few seconds.
  5. If the ESC then beeps once per cell followed by a long beep, calibration is done. Unplug the battery and move on to the speed-control sketch.
C++ (Arduino IDE)
1#include <Servo.h>
2
3// ESC gaz kalibrasyonu / ESC throttle calibration
4// PERVANEYI CIKAR! / REMOVE THE PROPELLER!
5Servo esc;
6const int ESC_PIN = 9;     // ESC sinyal kablosu / ESC signal wire
7const int MIN_US = 1000;   // gaz sıfır / zero throttle
8const int MAX_US = 2000;   // tam gaz / full throttle
9
10void setup() {
11  Serial.begin(9600);
12  esc.attach(ESC_PIN, MIN_US, MAX_US);
13  esc.writeMicroseconds(MAX_US);   // önce tam gaz / full throttle first
14  Serial.println(F("1) Bataryayi simdi tak / connect the battery now"));
15  Serial.println(F("2) Iki bip duyunca harf yaz + Enter / after two beeps type a letter + Enter"));
16  while (!Serial.available()) {}   // kullanıcıyı bekle / wait for the user
17  esc.writeMicroseconds(MIN_US);   // sonra gaz sıfır / then zero throttle
18  Serial.println(F("3) Uzun bip = kalibrasyon tamam / long beep = calibration done"));
19}
20
21void loop() {
22}
Most modern ESCs running BLHeli_S or BLHeli_32 firmware know the 1000–2000 µs range out of the box; calibrating does no harm anyway. If after calibration the motor starts at a very high throttle or never reaches full speed, make sure you use the same MIN_US and MAX_US values in the calibration sketch and the control sketch.

Speed control with a potentiometer and the Servo library

10 kΩ potentiometer
A 10 kΩ potentiometer stands in for a throttle stick: the wiper goes to A0, the outer pins to 5V and GND.

On the Arduino Uno the built-in Servo library is all you need. Because its write(0–180) command thinks in angles and uses a default range of 544–2400 µs, it is cleaner to send microseconds directly with writeMicroseconds() when driving an ESC. The sketch below arms the ESC, refuses to start the motor until the pot is back at zero and smooths changes with a ramp: even if you snap the pot to the end, throttle climbs from 0 to 100% in about 2 seconds. Servo basics are covered in What is a servo motor? and reading a pot in What is a potentiometer?.

C++ (Arduino IDE)
1#include <Servo.h>
2
3Servo esc;
4const int ESC_PIN = 9;     // ESC sinyal (beyaz/sarı) / ESC signal (white/yellow)
5const int POT_PIN = A0;    // gaz potansiyometresi / throttle potentiometer
6const int MIN_US = 1000;   // gaz sıfır / zero throttle
7const int MAX_US = 2000;   // tam gaz / full throttle
8const int STEP_US = 5;     // 10 ms'de en fazla değişim / max change per 10 ms
9
10int currentUs = MIN_US;    // şu anki gaz / current throttle
11
12void setup() {
13  Serial.begin(9600);
14  esc.attach(ESC_PIN, MIN_US, MAX_US);
15  esc.writeMicroseconds(MIN_US);       // arming: gaz sıfır / arming: zero throttle
16  Serial.println(F("ESC arming... potu sifirda tut / keep the pot at zero"));
17  delay(3000);                         // bip dizisini bekle / wait for the beep sequence
18  while (analogRead(POT_PIN) > 30) {   // güvenlik: pot sıfırda değilse bekle / safety: wait for pot at zero
19    delay(50);
20  }
21  Serial.println(F("Hazir / ready"));
22}
23
24void loop() {
25  int targetUs = map(analogRead(POT_PIN), 0, 1023, MIN_US, MAX_US);
26
27  // Rampa: ani gaz değişimini yumuşat / ramp: smooth sudden throttle changes
28  if (targetUs > currentUs + STEP_US) currentUs += STEP_US;
29  else if (targetUs < currentUs - STEP_US) currentUs -= STEP_US;
30  else currentUs = targetUs;
31  esc.writeMicroseconds(currentUs);
32
33  static unsigned long lastPrint = 0;
34  if (millis() - lastPrint >= 250) {   // 4 kez/sn yazdır / print 4 times per second
35    lastPrint = millis();
36    Serial.print(F("Gaz / throttle: %"));
37    Serial.println(map(currentUs, MIN_US, MAX_US, 0, 100));
38  }
39  delay(10);
40}
Code lineWhat it does
esc.attach(9, 1000, 2000)Starts the 50 Hz servo signal on D9 with a 1000–2000 µs range
esc.writeMicroseconds(1000)Zero throttle: the signal the ESC waits for to arm
delay(3000)Waits for the ESC to finish its beep sequence
while (analogRead(POT_PIN) > 30)Won't start the motor unless the pot is at zero
map(..., 0, 1023, 1000, 2000)Converts the pot reading to the 1000–2000 µs range
STEP_US = 5At most 5 µs change every 10 ms: full travel takes about 2 s

Driving an ESC with ESP32: 50 Hz signal with LEDC

The Arduino Servo library doesn't work on the ESP32; instead you can generate the signal yourself with LEDC, the chip's hardware PWM unit. At 50 Hz one period lasts 20,000 µs; at 16-bit resolution (0–65535) the duty value for any pulse width is duty = µs × 65535 / 20000: 3276 for 1000 µs and 6553 for 2000 µs. The code compiles on both the 2.x and 3.x ESP32 Arduino cores; the pot sits on GPIO 34, an ADC1 channel, so readings stay correct with Wi-Fi on. For a shortcut, the ESP32Servo library works just like the Uno code with esc.attach(13, 1000, 2000) and writeMicroseconds().

C++ (Arduino IDE)
1// ESP32 ile ESC sürme (LEDC, 50 Hz) / Driving an ESC with ESP32 (LEDC, 50 Hz)
2const int ESC_PIN = 13;     // ESC sinyal / ESC signal
3const int POT_PIN = 34;     // ADC1 potansiyometre / ADC1 potentiometer
4const int PWM_FREQ = 50;    // 50 Hz = 20 ms periyot / 20 ms period
5const int PWM_BITS = 16;    // 16 bit: 0-65535
6const int MIN_US = 1000;    // gaz sıfır / zero throttle
7const int MAX_US = 2000;    // tam gaz / full throttle
8
9#if ESP_ARDUINO_VERSION_MAJOR < 3
10const int PWM_CH = 0;       // 2.x çekirdeğinde LEDC kanalı / LEDC channel on core 2.x
11#endif
12
13// Mikrosaniyeyi görev değerine çevir / convert microseconds to a duty value
14void writeEscUs(int us) {
15  uint32_t duty = (uint32_t)us * 65535UL / 20000UL;
16#if ESP_ARDUINO_VERSION_MAJOR >= 3
17  ledcWrite(ESC_PIN, duty);           // 3.x: pin ile yaz / write by pin
18#else
19  ledcWrite(PWM_CH, duty);            // 2.x: kanal ile yaz / write by channel
20#endif
21}
22
23void setup() {
24  Serial.begin(115200);
25#if ESP_ARDUINO_VERSION_MAJOR >= 3
26  ledcAttach(ESC_PIN, PWM_FREQ, PWM_BITS);
27#else
28  ledcSetup(PWM_CH, PWM_FREQ, PWM_BITS);
29  ledcAttachPin(ESC_PIN, PWM_CH);
30#endif
31  writeEscUs(MIN_US);       // arming: gaz sıfır / arming: zero throttle
32  delay(3000);
33  while (analogRead(POT_PIN) > 100) {   // pot sıfıra inene kadar bekle / wait until the pot is at zero
34    delay(50);
35  }
36}
37
38void loop() {
39  int us = map(analogRead(POT_PIN), 0, 4095, MIN_US, MAX_US);
40  writeEscUs(us);
41  Serial.println(us);
42  delay(20);
43}
ESP32 and Pico signals are 3.3 V. Almost every common ESC reads that level without trouble; in the rare case your ESC doesn't see the signal, put a logic level shifter in between.

ESC with Raspberry Pi Pico (MicroPython)

On the Pico, MicroPython's PWM class lets you set the pulse width directly in nanoseconds: duty_ns(1000000) is a 1000 µs pulse. The pot connects to ADC0 on GP26, and read_u16() returns a value from 0 to 65535.

MicroPython
1from machine import Pin, PWM, ADC
2import time
3
4esc = PWM(Pin(15))          # ESC sinyal / ESC signal
5esc.freq(50)                # 50 Hz = 20 ms
6pot = ADC(26)               # GP26 = ADC0
7
8def write_us(us):
9    esc.duty_ns(us * 1000)  # mikrosaniye -> nanosaniye / microseconds -> nanoseconds
10
11write_us(1000)              # arming: gaz sıfır / zero throttle
12time.sleep(3)
13while pot.read_u16() > 2000:    # pot sıfıra inene kadar bekle / wait for pot at zero
14    time.sleep_ms(50)
15
16while True:
17    us = 1000 + pot.read_u16() * 1000 // 65535   # 1000-2000 µs
18    write_us(us)
19    time.sleep_ms(20)

Safe testing without a propeller: bench rules

  • The propeller goes on last: code, calibration and direction tests are done without it; fit the prop only when everything works and the motor is firmly mounted.
  • Unplug the battery first: before touching wires or code, disconnect the LiPo from the ESC; pulling the USB does not stop the motor, and the ESC may keep following the last signal it received.
  • Protected first power-up: a fuse or a "smoke stopper" between battery and ESC the first time saves the ESC if something is wired wrong.
  • Look after the LiPo: never discharge below 3.3 V per cell, don't use puffed packs, and charge only with a balance charger, always supervised.
  • Keep leads short and thick: thin wires heat up at 20 A; use at least 14–16 AWG between the ESC and the battery.
  • Check direction without the prop: if the motor spins backwards, swap any two of the three phase wires; no code change is needed.

Brushless motor project ideas

  • Airboat: mount an A2212 motor and prop on a foam hull and add a rudder at the back with a servo; steer it from your phone with an HC-05 Bluetooth module.
  • Thrust stand: attach the motor to an HX711 load cell and measure how many grams of thrust it makes at each throttle step.
  • Tachometer: use a Hall sensor and a magnet to measure the motor's real RPM and compare it with the KV calculation.
  • Powerful desk fan: put the propeller inside a protective cage and set the speed with a pot or automatically by temperature.
  • Wi-Fi throttle with ESP32: set the speed with a slider on your phone; reuse the web page from ESP32 servo control and add a timeout that cuts the throttle to zero if the connection drops.

Common mistakes and fixes

ProblemLikely causeFix
ESC keeps beeping, motor won't spinNot armed: no signal or throttle not at zeroCheck the GND wire and send 1000 µs first in setup()
Motor starts with the pot halfway upNot calibrated, or calibrated with a different rangeRepeat calibration with the code's 1000–2000 µs range
Motor twitches and stutters instead of spinningLoose phase wire or throttle too lowCheck the connectors and raise the throttle a little
Arduino resets when the motor startsVoltage dip or ground problemPower the Arduino from the BEC or a separate supply and join the grounds
write(0) doesn't stop the motor or acts oddlyThe Servo library defaults to 544–2400 µsUse attach(pin, 1000, 2000) and writeMicroseconds()
ESC or motor runs very hotProp too big for the motor or ESC rated too lowUse a smaller prop or a higher-amp ESC
On the Arduino Uno the Servo library uses Timer1, so with the ESC attached analogWrite() stops working on pins D9 and D10. For LEDs or other PWM outputs use D3, D5, D6 or D11.

Once you have the brushless motor and ESC pair figured out, you can move any servo project to a far more powerful motor. Since the ESC signal is the same as a servo signal, What is PWM? is a good refresher. In the BlueGrays app you'll find the potentiometer servo, joystick servo and ESP32 servo projects step by step with circuit diagrams and code, a good place to try the signal logic before moving on to this ESC sketch.

Frequently asked questions

How do you connect an ESC to an Arduino?

Connect the ESC's signal wire (white or yellow) to a digital pin such as D9 and the black or brown wire to Arduino GND. The red BEC wire can power the Arduino through the 5V pin, but leave it disconnected while the Arduino is on USB. The thick leads go to the LiPo battery and the three phase wires to the motor.

How do I calibrate an ESC with Arduino?

Send full throttle (2000 µs) from the Arduino, then plug in the battery; when the ESC gives two short beeps, drop to 1000 µs. The ESC confirms with cell-count beeps and a long beep and stores the range. Do it once per ESC, always without a propeller.

What does KV mean on a brushless motor?

KV is the motor's unloaded RPM per volt. A 1000 KV motor on 11.1 V spins at about 11,100 RPM. Low KV suits big propellers and torque; high KV suits small propellers and speed.

Can you run a brushless motor without an ESC?

Drone and plane motors draw far too much current for an Arduino pin and need a power stage that switches the phases, so they won't run without an ESC. Low-current gimbal motors can be driven with 3-phase drivers such as the L6234 or DRV8313 and the SimpleFOC library, but for high speed an ESC is the practical choice.

Why does my ESC keep beeping?

Usually the ESC sees no signal or the throttle is not at zero, so it hasn't armed. Check that the signal wire is on the right pin, GND is shared with the Arduino and setup() sends 1000 µs first. Some ESCs also beep as a low-battery warning.

What size ESC do I need for my brushless motor?

Take the motor's maximum current at full throttle and add 20–30% headroom; an A2212 that pulls 18 A pairs well with a 25 or 30 A ESC. Also make sure the ESC supports your battery's cell count, for example 2–4S.

See all projects
Servo Motor Operation with Potentiometer
AR-36Beginner
Premium

Servo Motor Operation with Potentiometer

As you turn the potentiometer knob, the servo motor's arm turns right along with it: one end of the knob means zero degrees, the other end means half a turn.

4.6(37)
54
ESP32 Servo Motor (Potentiometer Control)
ES-16Intermediate
Premium

ESP32 Servo Motor (Potentiometer Control)

In this project, we control an SG90 servo motor using a potentiometer. We adjust the servo angle by mapping the analog value read from the potentiometer to the 0–180-degree range. The ESP32Servo library generates servo signals on suitable output-capable GPIO pins of the ESP32; this project uses GPIO 18. This is a fundamental control method for robotic arms, camera gimbals, and automatic door mechanisms.

4.3(30)
42
Using a Servo Motor
AR-35Beginner
Premium

Using a Servo Motor

The arm of a small servo motor turns to three positions in turn: all the way to the start, right to the middle and all the way to the end, waiting two seconds at each stop.

4.7(49)
69
Servo Control with Joystick
AR-60Intermediate
Premium

Servo Control with Joystick

Steer two motors with a joystick, just like turning a security camera. Push the stick left or right and the bottom servo motor slowly turns, push it up or down and the top servo tilts up and down…

4.7(42)
58
ESP32 LED Brightness Control with a Potentiometer (Analog → PWM)
ES-13Intermediate
Premium

ESP32 LED Brightness Control with a Potentiometer (Analog → PWM)

In this project, we control the brightness of an LED analogically using a potentiometer. The ESP32's ADC pin reads the 0-3.3V voltage from the potentiometer, and this value is then converted into a PWM (Pulse Width Modulation) signal and sent to the LED. As a result, as you turn the potentiometer, the LED gradually brightens and dims. With Arduino Core 3.0+, analogWrite() can be used directly; on the ESP32-S2/S3, the ADC resolution is fixed at 12-bit.

4.4(20)
32
Bluetooth Controlled Car with L298N
AR-80Advanced
Premium

Bluetooth Controlled Car with L298N

Turn your phone into a remote and drive your own robot car. The Arduino receives commands from a remote-control app on your phone through a Bluetooth module and spins the wheels with a motor driver…

5.0(39)
66
Obstacle Avoidance Robot
AR-81Advanced
Premium

Obstacle Avoidance Robot

How about building a smart vehicle that finds its own way? The Obstacle Avoidance Robot constantly scans its surroundings thanks to the ultrasonic sensor in front of it.

5.0(38)
49