# Controlling ESC

**URL:** <https://forum.arduino.cc/t/controlling-esc/1334151>\
**Category:** Motors, Mechanics, Power and CNC\
**Created:** [December 20, 2024, 12:43pm UTC](https://forum.arduino.cc/t/controlling-esc/1334151 "2024-12-20T12:43:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![outbackhut](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/outbackhut/32/1099892_2.png) [@outbackhut](https://forum.arduino.cc/u/outbackhut)\
**Post date:** [December 20, 2024, 12:43pm UTC](https://forum.arduino.cc/t/controlling-esc/1334151/1 "2024-12-20T12:43:03Z")

</div>

I have this ESC:

> **[QX-MOTOR 50A 120A two-way waterproof Brushless ESC with UBEC Speed Controller...](https://qx-motor.co/product/qx-motor-50a-120a-two-way-waterproof-brushless-esc-with-ubec-speed-controller-support-2-6s-lipo-bec-5-5v-5a-for-rc-boat/)**
>
> QX-MOTOR 50A 120A two-way waterproof Brushless ESC with UBEC Speed Controller Support 2-6S Lipo BEC 5.5V/5A for RC Boat The electric regulator has high performance price ratio, adopts high-performance and low-power AVR 8-bit ATmega168 Series MCU, and...

And this motor:

> **[Surpass Hobby Rocket V2 supersonic 3674 4 poles 2150KV SP-036742-01-2150 | RC...](https://rcshop.net/motors/electric/moteurs-brushless/rocket-v2-supersonic-3674-4-poles-2150kv-en/)**

I want to control it with an arduino.

I've tried a couple random bits of code from the forum, all for use with various ESC.

The most basic one worked for a bit, then stopped.

I've attached it here:

```arduino
#include <Servo.h>

Servo ESC; // Create servo object to control the ESC

int speed = 0; // Starting speed of the motor
int increment = 1; // Speed change per iteration

void setup() {
  // Attach the ESC on pin 9
  ESC.attach(9, 1000, 2000); // (pin, min pulse width, max pulse width in microseconds)
}

void loop() {
  // Speeding up: Increase the speed gradually
  for (speed = 0; speed <= 180; speed++) {
    ESC.write(speed); // Send the PWM signal to the ESC
    delay(20); // Delay to control the speed change rate (adjust for smoother transition)
  }

  delay(1000); // Wait for 1 second at full speed

  // Slowing down: Decrease the speed gradually
  for (speed = 180; speed >= 0; speed--) {
    ESC.write(speed); // Send the PWM signal to the ESC
    delay(20); // Delay to control the speed change rate
  }

  delay(1000); // Wait for 1 second at stop
}

```

I have the GND pin (black) from the ESC connected to my Arduino GND, and the control pin (white) connected to pin 9. The red power pin is NOT connected.

I am completely out of my depth here, and I apologize in advance. Anyone with some knowledge or ideas would be very appreciated

---

<div class="post-metadata">

**Author:** ![outbackhut](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/outbackhut/32/1099892_2.png) [@outbackhut](https://forum.arduino.cc/u/outbackhut)\
**Post date:** [December 20, 2024, 12:56pm UTC](https://forum.arduino.cc/t/controlling-esc/1334151/2 "2024-12-20T12:56:15Z")

</div>

That being said, this code does some interesting things:

```arduino
//This code can be used for any purpose.

#include <Servo.h> //Using servo library to control ESC

Servo ESC1; //Creating a servo class with name as esc

int pos = 0; //Sets position variable

void arm(){

setSpeed(0); //Sets speed variable delay(1000);

}

void setSpeed(int speed){

int angle = map(speed, 0, 100, 0, 180); //maps servo to different speeds as percentage 

ESC1.write(angle);

}

void setup() {

ESC1.attach(9); //Adds ESC to certain pin. 

arm();

}

void loop() {

int speed; // speed variable

for(speed = 0; speed <= 70; speed += 5) { //Cycles speed up to 70% power for 1 second

setSpeed(speed); //Creates variable for speed to be used in in for loop

delay(1000);

}

delay(4000); //Stays on for 4 seconds

for(speed = 70; speed > 0; speed -= 5) { // Cycles speed down to 0% power for 1 second

setSpeed(speed); 

delay(1000);

}

setSpeed(0); //Sets speed variable to zero no matter what

delay(1000); //Turns off for 1 second

}

```

The motor starts by beeping once a second four times, silent for two seconds, then two quick beeps. After a number of seconds it repeats. Occasionally next it will spin at low speed for one second or less, other times it gives one long low beep. Other times it will rev up and spin for four seconds. Then other times it sits there and beeps one time a second endlessly until I reset it. Or two long beeps. Or one quick beep and a tiny rev.

Super super random.

Unfortunately, the sellers manual is barely understandable half chinese english and not helpful!

---

<div class="post-metadata">

**Author:** ![ua6em](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ua6em/32/930389_2.png) [@ua6em](https://forum.arduino.cc/u/ua6em)\
**Post date:** [December 20, 2024, 3:41pm UTC](https://forum.arduino.cc/t/controlling-esc/1334151/3 "2024-12-20T15:41:17Z")

</div>

```arduino
#include <Servo.h>
Servo motor;

int mot_pin = 9;   
int max_pwm = 2300;
int min_pwm = 800;
int pwm;
 
void setup(){
Serial.begin(9600);
motor.attach(mot_pin);
delay(1000);
motor.writeMicroseconds(max_pwm);
delay(2000);
motor.writeMicroseconds(min_pwm);
delay(4000);
}

void loop(){
  pwm = analogRead(A0);
  motor.writeMicroseconds(map(pwm,0,1023,800,2300));
}

```

---

<div class="post-metadata">

**Author:** ![jim-p](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jim-p/32/922840_2.png) [@jim-p](https://forum.arduino.cc/u/jim-p)\
**Post date:** [December 20, 2024, 4:50pm UTC](https://forum.arduino.cc/t/controlling-esc/1334151/4 "2024-12-20T16:50:32Z")

</div>

That ESC needs to be water cooled.  
Are you running water through it?

---

<div class="post-metadata">

**Author:** ![ua6em](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ua6em/32/930389_2.png) [@ua6em](https://forum.arduino.cc/u/ua6em)\
**Post date:** [December 20, 2024, 5:40pm UTC](https://forum.arduino.cc/t/controlling-esc/1334151/5 "2024-12-20T17:40:11Z")

</div>

> [@jim-p](#):
>
> That ESC needs to be water cooled

apparently the motor too

---

<div class="post-metadata">

**Author:** ![hallowed31](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hallowed31/32/1093680_2.png) [@hallowed31](https://forum.arduino.cc/u/hallowed31)\
**Post date:** [December 20, 2024, 5:52pm UTC](https://forum.arduino.cc/t/controlling-esc/1334151/6 "2024-12-20T17:52:12Z")

</div>

> [@outbackhut](#):
>
> The motor starts by beeping once a second four times, silent for two seconds, then two quick beeps. After a number of seconds it repeats. Occasionally next it will spin at low speed for one second or less, other times it gives one long low beep.

The beeping is probably the ESC, not the motor. Listen carefully to verify. The beep codes are telling you info about the signal. AI gives these common beep codes:

```arduino
Electronic speed controllers (ESCs) emit beeping tones to indicate their status and any errors. The beeps can be high or low, and have different frequencies and repeat rates. Here are some common ESC beep codes:
* **1 beep, 3 seconds** : Waiting for a signal
* **1 beep, 10 seconds** : Idle ESC tone
* **1 beep after commanding motor start** : Stall protection engaged
* **2 beeps, 3 seconds** : Invalid signal
* **3 beeps, 10 seconds** : Bad signal quality
* **3 beeps, once** : Booting to config mode
* **3 beeps, 5 seconds** : Over-temperature
* **4 beeps, once** : Bi-Directional DShot protocol
* **5 beeps, once** : Proshot protocol
* **6 beeps, 3 seconds** : Non-Zero Signal on Start

```

Yours may or may not conform to these codes.

---

<div class="post-metadata">

**Author:** ![elsawi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/elsawi/32/1100025_2.png) [@elsawi](https://forum.arduino.cc/u/elsawi)\
**Post date:** [December 20, 2024, 5:59pm UTC](https://forum.arduino.cc/t/controlling-esc/1334151/7 "2024-12-20T17:59:10Z")

</div>

You probably haven't calibrated the ESC. Try the following steps:

Connect ESC to signal (no power)  
Raise throttle all the way up  
Connect power  
Wait for beep  
Bring throttle all the way down  
You should hear multiple confirmation beeps  
The ESC should be calibrated now with minimum and maximum signal boundaries.

You only need to do this once. Upon load, the ESC should be receiving a signal (1000 for example). If not, it won't work. So give it a 1000 signal during setup, then you can control it inside of your loop using code.

If you don't have a transmitter integrated, then you you can use the "setup" code provided by ua6em to calibrate only once. Then comment it out and replace it by a 1000 signal.

---

<div class="post-metadata">

**Author:** ![outbackhut](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/outbackhut/32/1099892_2.png) [@outbackhut](https://forum.arduino.cc/u/outbackhut)\
**Post date:** [December 21, 2024, 12:16am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/8 "2024-12-21T00:16:33Z")

</div>

This gives me zero response from the motor. Not even a beep.

> [@jim-p](#):
>
> That ESC needs to be water cooled.  
> Are you running water through it?

Not as yet. According to my research the water cooling is only need when running the motor at high speed for long periods of time, or with high torque.

Currently I have it connected up, and everything is very cold. Do you think I need the water yet, or should it be ok?

> [@hallowed31](#):
>
> Listen carefully to verify.

It is the motor. Definitely NOT the ESC. I was very surprised - never heard a motor beep before!!  
Unfortunately I haven't heard any of those beep codes. And mine has multiple pitches too!!

> [@elsawi](#):
>
> So give it a 1000 signal during setup, then you can control it inside of your loop using code.

Something like this?

```arduino
#include <Servo.h>
Servo motor;

int mot_pin = 9;   
int max_pwm = 2300;
int min_pwm = 800;
int pwm;
 
void setup(){
Serial.begin(9600);
motor.attach(mot_pin);
delay(1000);
motor.writeMicroseconds(1000);
delay(2000);
//motor.writeMicroseconds(min_pwm);
//delay(4000);
}

void loop(){
  pwm = analogRead(A0);
  motor.writeMicroseconds(map(pwm,0,1023,800,2300));
}

```

---

<div class="post-metadata">

**Author:** ![outbackhut](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/outbackhut/32/1099892_2.png) [@outbackhut](https://forum.arduino.cc/u/outbackhut)\
**Post date:** [December 21, 2024, 12:20am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/9 "2024-12-21T00:20:09Z")

</div>

> **[New video by Daniel Van Nattan](https://photos.app.goo.gl/DEEW7ssvi2ZtprdBA)**

Here's a short video of some of the beeps.

I've even heard it do scales:

> **[New video by Daniel Van Nattan](https://photos.app.goo.gl/L68F5FUo1Z9La4dn8)**

---

<div class="post-metadata">

**Author:** ![elsawi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/elsawi/32/1100025_2.png) [@elsawi](https://forum.arduino.cc/u/elsawi)\
**Post date:** [December 21, 2024, 12:40am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/10 "2024-12-21T00:40:14Z")

</div>

Correct! Once the ESC is calibrated, the code above should work. Just make sure the output of your "map" function matches the range used when calibrating. So use the same 800-2300 to calibrate.

To verify that everything is working properly, the ESC should be beeping (with about a second delay between beeps) during the sketch upload, then it should go quite once it hits setup and receives the 1000 signal. But if you calibrated to start at 800, then use 800 instead of 1000 in setup, so the motor won't be spinning at all. Then as you send higher values, the motor will start spinning.

---

<div class="post-metadata">

**Author:** ![elsawi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/elsawi/32/1100025_2.png) [@elsawi](https://forum.arduino.cc/u/elsawi)\
**Post date:** [December 21, 2024, 12:41am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/11 "2024-12-21T00:41:30Z")

</div>

Alternatively, you may just want to stick to 1000-2000 for calibration and mapping. That's the typical range used and the range provided by typical transmitters.

---

<div class="post-metadata">

**Author:** ![elsawi](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/elsawi/32/1100025_2.png) [@elsawi](https://forum.arduino.cc/u/elsawi)\
**Post date:** [December 21, 2024, 12:42am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/12 "2024-12-21T00:42:58Z")

</div>

Finally, I don't see the ESC in the video, so there's a small change that it requires a different calibration process; however, the process given works for most ESCs.

---

<div class="post-metadata">

**Author:** ![outbackhut](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/outbackhut/32/1099892_2.png) [@outbackhut](https://forum.arduino.cc/u/outbackhut)\
**Post date:** [December 21, 2024, 12:43am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/13 "2024-12-21T00:43:55Z")

</div>

> [@elsawi](#):
>
> To verify that everything is working properly, the ESC should be beeping (with about a second delay between beeps) during the sketch upload

Nothing. No beeps. Once the code hits set up, it beeps once a second for four seconds, followed by two quick beeps.

The motor does not spin. Not with this code. Doesn't matter what A0 is reading - the motor does nothing. Ever

---

<div class="post-metadata">

**Author:** ![outbackhut](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/outbackhut/32/1099892_2.png) [@outbackhut](https://forum.arduino.cc/u/outbackhut)\
**Post date:** [December 21, 2024, 12:44am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/14 "2024-12-21T00:44:23Z")

</div>

> [@elsawi](#):
>
> Finally, I don't see the ESC in the video

Hold on, I'll get you a photo

---

<div class="post-metadata">

**Author:** ![outbackhut](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/outbackhut/32/1099892_2.png) [@outbackhut](https://forum.arduino.cc/u/outbackhut)\
**Post date:** [December 21, 2024, 12:48am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/15 "2024-12-21T00:48:55Z")

</div>

![20241221_114722](https://europe1.discourse-cdn.com/arduino/original/4X/f/8/0/f804a9c04c168de40a3a78bf92949bd1245bf26a.jpeg)

Yes, I'm using alligator clips. To be perfectly blunt, I could not find anything that actually certifies which ESC wire goes to which motor wire. They aren't colour matched, the motor manual didn't say, and the ESC manual was less than useless.

The current configuration works in that occasionally I'll get a response. Plus it matches the dodgy diagram in the ESC manual exactly

---

<div class="post-metadata">

**Author:** ![hallowed31](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hallowed31/32/1093680_2.png) [@hallowed31](https://forum.arduino.cc/u/hallowed31)\
**Post date:** [December 21, 2024, 12:57am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/16 "2024-12-21T00:57:33Z")

</div>

> [@outbackhut](#):
>
> It is the motor. Definitely NOT the ESC. I was very surprised - never heard a motor beep before!!  
> Unfortunately I haven't heard any of those beep codes. And mine has multiple pitches too!!

Yikes. Thanks for clarifying though.

Found this document that does mention motors beeping. First I've heard of the motor beeping, huh.

> **[Supersonic-V2-50A-60A-90A-110A-ESC-USER-MANUAL-11024-1077-17.pdf](https://cdn.surpass-hobby.com/wp-content/uploads/sites/24/2024/03/Supersonic-V2-50A-60A-90A-110A-ESC-USER-MANUAL-11024-1077-17.pdf)**

Good luck.

---

<div class="post-metadata">

**Author:** ![outbackhut](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/outbackhut/32/1099892_2.png) [@outbackhut](https://forum.arduino.cc/u/outbackhut)\
**Post date:** [December 21, 2024, 12:58am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/17 "2024-12-21T00:58:43Z")

</div>

Did you see my second video containing it beeping scales?? Next it's gonna get up and talk, or sing opera....

---

<div class="post-metadata">

**Author:** ![outbackhut](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/outbackhut/32/1099892_2.png) [@outbackhut](https://forum.arduino.cc/u/outbackhut)\
**Post date:** [December 21, 2024, 1:00am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/18 "2024-12-21T01:00:14Z")

</div>

> [@hallowed31](#):
>
> this document

Probably a good idea for me to get the supersonic ESC - though I do need a waterproof one as this is going in a RC boat

---

<div class="post-metadata">

**Author:** ![ua6em](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ua6em/32/930389_2.png) [@ua6em](https://forum.arduino.cc/u/ua6em)\
**Post date:** [December 21, 2024, 1:16am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/19 "2024-12-21T01:16:42Z")

</div>

```arduino
#include <Servo.h>
Servo motor;

int mot_pin = 9;   
int max_pwm = 2300;
int min_pwm = 800;
int pwm;
 
void setup(){
Serial.begin(9600);
motor.attach(mot_pin);
delay(1000);
motor.writeMicroseconds(1500);
delay(2000);
//motor.writeMicroseconds(min_pwm);
//delay(4000);
}

void loop(){
 // R = 2.5V
  pwm = analogRead(A0);
  motor.writeMicroseconds(map(pwm,0,1023,800,2300));
}

```

---

<div class="post-metadata">

**Author:** ![hallowed31](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hallowed31/32/1093680_2.png) [@hallowed31](https://forum.arduino.cc/u/hallowed31)\
**Post date:** [December 21, 2024, 1:19am UTC](https://forum.arduino.cc/t/controlling-esc/1334151/20 "2024-12-21T01:19:30Z")

</div>

> [@outbackhut](#):
>
> Probably a good idea for me to get the supersonic ESC - though I do need a waterproof one as this is going in a RC boat

Maybe, sorry I can't say at this point.

What battery are you using? Apologies if you already mentioned it.

Are you sure those alligator clips and wires are conducting properly? I've had it where it was just a broken test wire that was fouling things up, maybe that's the case?

[Next page](https://forum.arduino.cc/t/controlling-esc/1334151.md?page=2)
