ESC doesn't react after initializing

Hey folks,
i have a Hobbyking 80A SBEC ESC and I don't know why the motor doesn't react after initializing the ESC and pressing the deadmen switch for security reasons. Have I the wrong values for that?
Btw I am using a analog stick for controlling the ESC with lowest value of 18 and the center value is 796 and 1023 as the highest.

Greetings
Mainsedora

#include "ESC.h"
#define SPEED_MIN (1000)                                          // Set the Minimum Speed in microseconds
#define SPEED_MAX (2000)                                          // Set the Minimum Speed in microseconds                                           
ESC myESC (2, SPEED_MIN, SPEED_MAX, 500);                         // ESC_Name (ESC PIN, Minimum Value, Maximum Value, Default Speed, Arm Value)
int oESC, deadmen = 1, cruiseButton, pot = A0, val, curval = 1000;           // Variable for the speed sent to the ESC
void setup() {
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);                                   // LED Visual Output
  pinMode(pot, INPUT);
  pinMode(deadmen, INPUT);
  myESC.arm();                                                    // Send the Arm value so the ESC will be ready to take commands
  digitalWrite(LED_BUILTIN, HIGH);                                // LED High Once Armed
  delay (5000);                                                   // Wait for a while
  Serial.println("init finished");
}
void loop() {
  val = analogRead(pot);                                          //read potentiometer value
  Serial.println(val, DEC);
  val = map(val, 800, 1023, 1000, 2000);                          //map potentiomater value (0-1024 to 1000-2000 micro seconds);
  if (digitalRead(deadmen) == LOW) {                              //check if deadman switch is pressed
    if (digitalRead(cruiseButton) == HIGH) {                      //check if cruise button is pressed, if it is dont modify the curval
      // do nothing to curval
    } else if (curval < val) {                                    //check if curval is less than potentiometers mapped value
      curval = curval + 5;                                        // if it is less, add 5 to the curval
    } else if (curval > val) {                                    //check if curval is more than potentiometers mapped value
      curval = curval - 5;                                        //if it is more, remove 5 from the curval
    }
  } else if (curval > 1000) {                                     //if deadmans switch isnt turned and curval is more than 1000ms (throttle down value)
    curval = curval - 5;                                          //remove 5 from curval to start slowing down if above condition is true
  }
  myESC.speed(curval);                                            //write microseconds to esc
  delay(50);                                                      //delay the loop 50ms
}

Do you have a link to your ESC? Just giving the name makes us guess at which one you have.
If you post a link, we can go read the manual.

I am not familiar with the ESC library. Is it like the servo library?

If I were troubleshooting this, I would yank out everything that was not dealing with the reading of the pot, the writing to the ESC and maybe any debug prints. Get the communication worked out, and then add in switches for deadman and cruise.

The ESC.h library has several useful example programs. Have you tried any of them? ESC_Ramp and ESC_Knob are both good. Running one of those will let you know that your wiring and power are o.k.

Steve

Here is the link to the ESC

and here is the library

The examples are working fine, but my code has a delay function, so that the motor slowly accelerates and not accelerates instantly to max RPM. When I use ESC.stop(), the motor stops and then the esc goes into programming mode.

Put a Serial.println(curval) in just before the myESC.speed(curval) so you can see exactly what values you're writing to the ESC.

Steve

Well, the curval variable, that I have set to 1000, is changing not, when I pull the analog stick to 1023 and pressed the deadmen switch.

Well if it's never changing that explains why the motor does nothing. There's only one place where curval is ever increased so try another Serial.print() or two to see if it ever gets there.

If not it might have something to do with the state of cruiseButton, which is never properly initialised so it's anyone's guess what doing a digitalRead() of it will give you.

Steve

I will try it in the afternoon. Maybe cruiseButton has to be low.

After re-reviewing my code, i found the criminal one. It was if (digitalRead(cruiseButton) == HIGH). I altered the HIGH to LOW and then it worked. Btw I will commit my code to github for everyone, when the wifi is implemented in. So everyone can use it for his project, like electric skateboards.