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!