controlling Parallax continous servos using joystick(pot)

Hello fellow Arduino users.

I`m kinda new to C++ programming, but quite interested in this programming language.
Normally I use PLC in my work, so this is something new for me.

The thing I wanna do with my program is to control the direction of 2 ea Parallax continuos servos, using two pot meters.

I want tor be able to:

-1. Start, and run both servos in opposite direction using the joystick intput-value from 600-1024
-2. Stop the servos when the joystick is in the mid-position (input value fluctuates 520-530)
-3. Start, and run both servos in inverted direction relative to statement "1" using the joystick intput-value from 0-400

The problem I run into is when using "if" functionality.. I cannot get the servos to run as desired. :~

#include <Servo.h>            //intialize servoSUBprogram

Servo servoX;        // Create Servo object to control the servo 
Servo servoY;        // Create Servo object to control the servo

int X = A0;                   //map variabel x to A0
int Y = A1;                   //map variabel y to A1
 
int pos = 650;                //variable
int neg = 350;                //variable
int mid = (450,550);          //variable

void setup(){
  Serial.begin(9600);         //initialize serial com 
  
 }

void loop(){
  
  int X = analogRead(A0);       //reads the value of the potentiometer (value between 0 and 1023) 
  int Y = analogRead(A1);       //reads the value of the potentiometer (value between 0 and 1023) 
 
  servoX.attach(7);  // Servo is connected to digital pin 7 
  servoY.attach(8);  // Servo is connected to digital pin 8 
 
  Serial.print("pot X");        // unique header to identify start of message
  Serial.print(",");            // comma to differenciate 
  Serial.print( X ,DEC);        // print variable in DEC
  Serial.print("     ");        // space 
  Serial.print("pot Y");        // unique header to identify start of message
  Serial.print(",");            // comma to differenciate 
  Serial.print( Y ,DEC);        // print variable in DEC
  Serial.print(",");            // note that a comma is sent after the last field
  Serial.println();             // send a cr/lf
  delay(1);                     // wait ms 
  
  if (Y>pos){
    servoX.writeMicroseconds(1300);  // servo direction
    servoY.writeMicroseconds(1700);  // opposite direction
    }
    
  if (Y<neg){
    servoX.writeMicroseconds(1700);  // servo direction
    servoY.writeMicroseconds(1300);  // opposite direction
  } 
  if (Y=mid){
    servoX.writeMicroseconds(1500);  // servo stop
    servoY.writeMicroseconds(1500);  // servo stop
  }
  
}
if (Y=mid)

The usual.

if (Y=mid)

suppose to be

if (Y==mid)

single "=" assign
double "=" compare

If there are only three actions then you don't need all three conditions:

  if (Y>pos)
  {
    // forwards
    servoX.writeMicroseconds(1300);  // servo direction
    servoY.writeMicroseconds(1700);  // opposite direction
  }
  else if (Y<neg)
  {
    // reverse
    servoX.writeMicroseconds(1700);  // servo direction
    servoY.writeMicroseconds(1300);  // opposite direction
  } 
  else 
  {
    // stop
    servoX.writeMicroseconds(1500);  // servo stop
    servoY.writeMicroseconds(1500);  // servo stop
  }
int mid = (450,550);

I missed that one.
I'm a bit surprised the compiler did too

AWOL:

int mid = (450,550);

I missed that one.
I'm a bit surprised the compiler did too

The value of a comma-separated list of values is the last value in the list, so it looks like a legitimate assignment - although unlikely to do what was intended.

Yeah, I posted that from my phone, and couldn't see properly whether they were braces or parentheses.