Alien Power Systems ESC Control with Arduino

Hi,

I am trying to control an ESC connected to a brushless motor with the help of Arduino.
The purpose of my program is just to familiarize myself with controlling the speed of the motor.
My esc is connected to a pwm pin and the program sends different output values using ESC.write(value); (from the Servo library);

From what I understood, the write() function can have 0-179 as an argument, 0 being full reverse throttle, 90 being stop, 179 being full FW throttle. Now when I tell the ESC to run at certain values, it does not respond at all sometimes, and it works some other times. It has a very unpredictable behavior and I am not sure which values work (yet alone if I’m doing the right thing with write() ).

Here is my code:

#include <Servo.h>

Servo esc;

void setup() {
esc.attach(9);
}

void loop() {
int throttle;

for(throttle = 90; throttle < 179; throttle++)
{
esc.write(throttle);
delay(100);
}
}

The ESC and motor is here:

Thanks!

Try this test sketch, type a number from 0 to 180 into the serial monitor and hit [ENTER], start at 90, the motor should stand still or run very slow, type 80, the motor should run slowly, type 100, motor should run slowly in opposite direction, play with different numbers to see how system responds.

#include <Servo.h>
Servo servo;


int pos = 0;

void setup() {
  // initialize serial:
  Serial.begin(9600); //set serial monitor baud rate to match
  servo.attach(9);
}

void loop() {
  // if there's any serial available, read it:
  while (Serial.available() > 0) {

    // look for the next valid integer in the incoming serial stream:
    int pos = Serial.parseInt();
    pos = constrain(pos, 0, 180);
    servo.write(pos); 
    Serial.println(servo.read());
  }
}