Trouble with brushless drone motor, ESC, and Arduino Uno

Hi, I am brand new to brushless drone motors and ESCs. For a recent project, I want to control a brushless drone motor using an Arduino Uno. Most tutorials I have found use a potentiometer and an analog pin to control the speed, but I want to do so using only the serial monitor without a potentiometer.
I am using a BLHELI 20A ESC from fingertech robotics, as well as a D-Power Series, D2822 Brushless Drone Motor. Eventually, they will be powered with a very small LiPo, but currently I am using a 9v.

This is my most recent code, it is driven from some Youtube tutorial.

#include <Servo.h>

Servo ESC;     // create servo object to control the ESC
 
int val = 10;


void setup() {

Serial.begin(9600);
ESC.attach(9);//,1000,2000); // (pin, min pulse width, max pulse width in microseconds) 
delay(1);
ESC.write(10); // This is supposed to arm the ESC
delay(5000);
  Serial.println("Ready!");

}

void loop() { 

  
  while (Serial.available() > 0)
  {
    int val = Serial.parseInt();
   Serial.println(val);
   ESC.write(val);
  }
  }


This is the wiring diagram. There is a potentiometer in the circuit, but it is not being used.

I have successfully controlled the motor using a potentiometer, but when I cut it out of the circuit using the code above, and I type in the highest values in the code, the motor won't spin, rather beep.
Weirdly, the motor will spin if I increase the value in the serial monitor by 10 or 20, and slowly walk it up to 160, but I can't pass this value. I believe it should go up to about 180.
Also, sometimes the motor will stop spinning about 5 seconds after I stop entering in values.
How can I code the motor to reliably spin at the input of a value in the serial monitor, without needing to be walked up to full speed?
Again, I am very new the ESCs, and anything will help!
Thanks!

1 Like

The battery in the picture is useless for things like motors. It delivers 9 volt but no amperes, only milliamps. Put it back where it came from. Try 6xAA batteries instead.

1 Like

Don't you have to program that ESC with the min and max throttle positions

1 Like

I do not know. How would I do that?

1 Like

Also, if I use a line of AA batteries, will that help increase its speed? If so, that would be great!

1 Like

For what? That motor, driving a propeller, is rated 260 Watts, more than 20 Amps at 12 volts.
ESCs usually have to be "armed" (stupid word) by setting the minimum and maximum throttle settings. Check the ESCs user manual (if you have it).

1 Like

The exact motor I am using is this one that is linked
Amazon Link
It is being used for a spinner in an NRC plastic combat bot.
How would I set the minimum and maximum throttle values? I thought I could do that in the section of code that was commented out after the line where I declared what pin the ESC was attached to. Would uncommenting it set the values? Also, for my case would the values already in the comment, 1000 to 2000, be sufficient?
Thanks!

1 Like

Hi,
I am still having the issue with the ESC needing to be stepped up to full power and being unreliable.
Does anyone know if they could help me with this?
Thanks!

1 Like

Hi!
I am still having issues with the setup.
Anything will help!
Thanks!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.