ESC Coding

Hey everyone,

I have run into a simple problem.

I have successfully armed my ESC and controlled my motor through the serial monitor with the code below.

/*
Coded by Marjan Olesch
Sketch from Insctructables.com
Open source - do what you want with this code!
*/
#include <Servo.h>

int value = 0; // set values you need to zero

Servo firstESC, secondESC; //Create as much as Servoobject you want. You can controll 2 or more Servos at the same time

void setup() {

firstESC.attach(9); // attached to pin 9 I just do this with 1 Servo
Serial.begin(9600); // start serial at 9600 baud

}

void loop() {

//First connect your ESC WITHOUT Arming. Then Open Serial and follo Instructions

firstESC.writeMicroseconds(value);

if(Serial.available())
value = Serial.parseInt(); // Parse an Integer from Serial

}

However, I want the ESC to arm on its own, during the void setup, then run at a constant speed. Normally to arm using the serial monitor I enter the low value (1000), then high (2000), and back to low (1000). The ESC is then armed. Here is what I wrote, but the ESC gives me 2 beeps (I think meaning its recognized a low signal), then gives a low constant beep meaning some signal is off.

#include <Servo.h>

int value = 0; // set values you need to zero

Servo firstESC, secondESC; //Create as much as Servoobject you want. You can controll 2 or more Servos at the same time

void setup() {

firstESC.attach(9); // attached to pin 9 I just do this with 1 ESC
firstESC.writeMicroseconds(1000); // low 1 ms pulse
delayMicroseconds(2000); // delay to give ESC time to recognize signal
firstESC.writeMicroseconds(2000); // high 2 ms pulse
delayMicroseconds(2000);
firstESC.writeMicroseconds(1000); // low 1 ms pulse, ESC should now be armed
delayMicroseconds(2000);

}

void loop() {

firstESC.writeMicroseconds(1300); //constant speed for motor to run

}

delayMicroseconds(2000);           // delay to give ESC time to recognize signal

This is a very short period of time. Try using delay() instead, which will make the delay 2 seconds.

Worked like a charm

Good to hear.