esc wont calibrate setup

I want to calibrate a motor in the setup ,cause i dont use it on a transmitter..
It works with this :

motor.writeMicroseconds(MAX_SIGNAL);

// Wait for input
while (!Serial.available());
Serial.read();

// Send min output
Serial.println("Sending minimum output");
motor.writeMicroseconds(MIN_SIGNAL);

But i can't use the serial monitor when its a finished product.

so i tried this,but i keeps going into programming mode:

motor.writeMicroseconds(MAX_SIGNAL);
delay(2000);
motor.writeMicroseconds(MIN_SIGNAL);

How?

You haven't included anything useful.

What is 'the setup'?
What transmitter?
What programming mode?

Post your full code and an overview of the system

the setup = setup{} (in arduino C)
transmitter (cant calibrate with a joystick)( the motor has to keep spinning at the same speed)
programming mode of the ESC .

#include <Servo.h>

#define MAX_SIGNAL 2000
#define MIN_SIGNAL 700

Servo myServo,ondermotor,achtermotor; // create a servo object
int angle;
int Servoo = 3;
int Achter = 4;
int ch1; //servo op ch1
int ch2=8;
int led = 13;
int kracht = 160; // regelen wanneer de hovercraft gebouwt is
int snelheid;

void setup() {
myServo.attach(10);// servo op pwm10
ondermotor.attach(11);// ondermotor op pwm1
achtermotor.attach(12);

pinMode(ch1, INPUT); // Set our input and output pins as such
pinMode(ch2, INPUT); // Set our input and output pins as such

ondermotor.writeMicroseconds(MAX_SIGNAL);
delay(2000);
ondermotor.writeMicroseconds(MIN_SIGNAL);
Serial.begin(9600); //initialise serial
}

void loop() {

ch1 = pulseIn(Servoo, HIGH, 20000); // Read the pulse width
ch2 = pulseIn(Achter, HIGH,20000);

// 1350 -

if (ch1 < 1250 ) {
angle = 55 ;
}
else if (ch1 < 1400 ) {
angle = 61 ;
}
else if (ch1 < 1550 ) {
angle = 67 ;
}
else if (ch1 < 1700) {
angle = 73 ;
}
else if (ch1 < 1850) {
angle = 79 ;
}
else if (ch1 < 2000) {
angle = 85 ;
}
else if (ch1 > 2150) {
angle = 90 ;
}

Serial.print("Channel 1:"); // Printing the value of
Serial.print(ch1); // each channel
Serial.print("\t");
Serial.print("Channel 2:"); // Printing the value of
Serial.print(ch2); // each channel
Serial.print("\t");
//Degree 0............90.............180 ,Speed -%100...........%0............+%100 (- and + shows the direction of motor)

myServo.write(angle);
ondermotor.write(140);
achtermotor.write(snelheid);

delay(10);
}

You should put code tags around your code, it makes the forum more readable.

Your arduino is probably in brown-out reset due to a connection problem. How much power are you drawing from the arduino supply?

Reset will take you back into the setup

the 5 v to power the receiver..

How about the servo's power supply? How is this connected?

As a double check you could add an led blink with a delay to check it is definitely the setup routine it returns to not a problem with the servo algorithm.

Just a thought but the serial monitor automatically resets the arduino when it connects, is this an issue?

Do ESC's normally need full throttle before power is applied to them to enter calibration mode?