Control Two Motors with esc using joystick? I need help joystick seems uncenter

Hi, I was coding and trying to figure out whether i could control two escs with thier motors using a joystick. The issues is that the center actually reads x axis 504 and y axis 513 so this cause issues as joysticks center should be 0,0. This in turn cause the motor to spin even if the motor is at its center. Heres the code for it that doesnt work. I assume some kind of calibration is needed?

#include <Servo.h> //include sevo library
Servo esc;  //name my servo
int pos = 0;     // variable to store the servo position 
int potTwoX = 14; 
int potOneY = 13;  //stores variable for potentiometer one
int potValue;      //varaible to read pot 1 value
int lowend;    //variable for low end of pot
int highend;   //variable for high end of pot
int potValue2;
int lowend2;    //variable for low end of pot
int highend2;
void setup() {                
  esc.attach(10);  //attach servo to digital pin 3
}

void loop() {
  potValue = analogRead(potOneY);               //read analog pin and set to potValue var
  potValue2 = analogRead(potTwoX);    
  lowend = map(potValue, 0, 450, 0, 90);       //define low end of pot
  highend = map(potValue, 550, 1000, 90, 180); //define high end of pot
  lowend2 = map(potValue2, 0, 450, 0, 90);       //define low end of pot
  highend2 = map(potValue2, 550, 1000, 90, 180); //define high end of pot
  if (potValue <=450 && potValue2 <= 450)
  {
  esc.write(lowend);
  }
  if (potValue >= 550 && potValue2 >=550)
  {
  esc.write(highend);
  }
}
//if statements remove 450 to 550 values from center portion of pot

Which ESC do you have? Some ESCs only have forward rotation, with 0 being stop and 180 being full throttle.
Others (often RC car ESCs) have forward and reverse. Which do you have?

For your joystick calibration, I would use something like this:

Read the 2 joystick values and print then to the monitor.
What is the high value? What is the low value? What is the centered value?
Wiggle the joystick a bit and see if the center value changes much. You need to know if you need a deadband in the middle to account for this variance.

The esc i use are for quadcopters. The name is rctimer sk-30a they are from europe. To anwser your question the high value is 514 and the low value is 506 though the centerd value i thought should be 0,0. Having 0,0 would make using the map function easier. :frowning: From the center out the numbers change a ton from 0-1023 just like an analog pin should?

Try:

rawVal = analogRead(aInPin);
val = rawVal - 511;

i did that it has centered to 0,0 after doing some mapping. Now this issue is i dont know how to get the motor to work with the esc