Controlling a brushless DC motor using an (ESC) and a potentiometer with an Arduino Uno

Controlling a brushless DC (BLDC) motor using an Electronic Speed Controller (ESC) and a potentiometer with an Arduino Uno allows for adjustable motor speed control. This guide will walk you through the process of setting up the components and writing the code to achieve this.

Materials Needed

  • Arduino Uno board
  • Brushless DC motor
  • Electronic Speed Controller (ESC)
  • Potentiometer (10kΩ)
  • Power source (e.g., LiPo battery suitable for your ESC and motor)
  • Breadboard
  • Jumper wires
  • USB cable for Arduino

Circuit Diagram

Here’s a basic circuit diagram:


  1. Connect the signal wire (usually white or yellow) of the ESC to a digital PWM pin on the Arduino (e.g., pin 9).
  2. Connect the ground wire (usually black or brown) of the ESC to the GND pin on the Arduino.
  3. Connect the power wire (usually red) of the ESC to an appropriate power source (e.g., a LiPo battery).
  4. Connect the potentiometer:
    • One terminal to 5V on the Arduino.
    • The second terminal to GND on the Arduino.
    • The wiper (middle pin) to an analog input pin on the Arduino (e.g., A0).


  1. Connect the Components:

    • Connect the ESC signal wire to digital pin 9 on the Arduino.
    • Connect the ESC ground wire to a GND pin on the Arduino.
    • Connect the ESC power wire to the positive terminal of the battery.
    • Connect the negative terminal of the battery to the GND pin on the Arduino to ensure a common ground.
    • Connect the potentiometer’s one terminal to 5V on the Arduino.
    • Connect the potentiometer’s other terminal to GND on the Arduino.
    • Connect the potentiometer’s wiper (middle pin) to analog input pin A0 on the Arduino.
  2. Set Up the Arduino IDE:

    • Download and install the Arduino IDE if you haven’t already.
    • Connect your Arduino Uno to your computer using the USB cable.
    • Open the Arduino IDE and select your board and port from the “Tools” menu:
      • Board: “Arduino Uno”
      • Port: Select the appropriate port that your Arduino is connected to.
  3. Write the Code:

    • Open a new sketch in the Arduino IDE and write the following code to control the BLDC motor using a potentiometer:
#include <Servo.h>

// Create a Servo object to control the ESC
Servo esc;

// Define the ESC signal pin and the potentiometer pin
const int escPin = 9;
const int potPin = A0;

void setup() {
  // Attach the ESC on pin 9 to the esc object
  esc.attach(escPin, 1000, 2000); // (pin, min pulse width, max pulse width)

  // Initialize the ESC signal to zero (typically by setting it to the minimum pulse width)
  delay(2000); // Wait for 2 seconds for the ESC to initialize

void loop() {
  // Read the potentiometer value (0 to 1023)
  int potValue = analogRead(potPin);

  // Map the potentiometer value to a range of 1000 to 2000 microseconds
  int escValue = map(potValue, 0, 1023, 1000, 2000);

  // Write the mapped value to the ESC

  // Small delay to stabilize the reading

  1. Upload the Code:
    • Click the “Upload” button (right arrow icon) in the Arduino IDE to compile and upload the code to your Arduino Uno.
    • After the upload is complete, the motor speed should vary based on the position of the potentiometer.

How It Works

  • The Servo.h library is used to control the ESC as if it were a servo motor.
  • The esc.attach(escPin, 1000, 2000) function attaches the ESC to the specified pin with the specified minimum and maximum pulse widths (in microseconds).
  • In the setup() function, esc.writeMicroseconds(1000) initializes the ESC by sending a minimum pulse width signal, and a delay of 2 seconds is given for the ESC to initialize.
  • In the loop() function:
    • The potentiometer value is read using analogRead(potPin), which returns a value between 0 and 1023.
    • The map() function converts this value to a range suitable for the ESC (1000 to 2000 microseconds).
    • The mapped value is then written to the ESC using esc.writeMicroseconds(escValue), controlling the motor speed.

Safety Precautions

  • Ensure all connections are secure to avoid shorts and potential damage.
  • Use an appropriate power source for your ESC and motor to prevent overheating or damage.
  • Be cautious when handling LiPo batteries, as they can be dangerous if mishandled.


Congratulations! You’ve successfully controlled a brushless DC motor using an ESC and a potentiometer with an Arduino Uno. This project provides a great introduction to motor control and can be expanded to more complex applications in robotics and automation. Keep experimenting and exploring the exciting world of electronics with Arduino!

Feel free to share your experiences or ask questions in the comments below. Happy tinkering!

Related Articles