Hey guys, I am trying to run a drone motor through an ESC I have. (The esc is the "AfroESC 20A" Its manual is here: https://bit.ly/2St6qZ1), however, I am having trouble understanding how to run it.
Based off of the manual, its speeds are determined by the range 1060 -1860 microseconds, and to arm it, you use less than 1060. Thus, I thought that a simple code would allow it to run by simply writing the speed in microseconds to it, yet when I run the following code, although the ESC does arm, the motor does not spin beyond a small jitter motion at the servo.writeMicroseconds(500) part. I am not certain what is wrong, so any help would be much appreciated!! Thank you!
Here is the code:
#include <Servo.h>
byte servoPin = 9;
Servo servo;
void setup() {
servo.attach(servoPin);
Serial.begin(9600);
servo.writeMicroseconds(1054); // send "stop" signal to ESC, also this should arm it.
delay(1000); // delay to allow the ESC to recognize the stopped signal
}
void loop() {
int numberofsteps = 100;
int nextspeed;
for (int mystep = 0; mystep < numberofsteps; mystep++) //take 100 incraments from slowest speed to requested speed
{
nextspeed = 1064 + (1337 - 1064) * mystep / numberofsteps;
servo.writeMicroseconds(nextspeed);//set the motor speed (yet does nothing)
Serial.println(nextspeed);
delay(1000 / numberofsteps);
}
Serial.println("Running...");
servo.writeMicroseconds(1337); //supposidly should set the speed to run at, yet does nothing
delay(3000);
Serial.println("Stopping...");
servo.writeMicroseconds(500);
delay(5000);
Serial.println("continue");
}