How to reverse Bipolor motor direction with Joystick

Here is the code that I am currently working on

//Assigning joystick shield pin

int speed_Y = 0; 
int joystickValue_Y = 0;
int centerYValue = 0;

const int Y_THRESHHOLD_LOW = 500;
const int Y_THRESHHOLD_HIGH = 510; 


//Assigning Joystick Shield pins
int pinStickY = 1;
//Assigning Easydriver 
int pinSTEP = 13;       // Step 
int pinDIR  = 12;       // Direction
int pinMS1  = 11;       // MicroStep 1
int pinSLP  = 10;       // Sleep
int pinMS2  =  9;       // MicroStep 2
int pinENA  =  8;       // Enable


void setup() {
pinMode(pinSTEP, OUTPUT);
pinMode(pinDIR, OUTPUT);
pinMode(pinENA, OUTPUT);

}

void loop() {

  joystickValue_Y = analogRead(pinStickY); //Reads number for joystick in Y-Dir
  
  centerYValue = joystickValue_Y - 516; //516 is the center position of MY joystiuck shield
 centerYValue = abs(centerYValue);//If negative, turns nonnegative
speed_Y = 1000/centerYValue; //Inverts the value and scales as needed. Change the value as needed!!!! The delay between steps determines the speed of the motor, delay up = speed down.

if (joystickValue_Y > Y_THRESHHOLD_HIGH){
 digitalWrite(pinENA, LOW); //Enable
digitalWrite(pinDIR, HIGH); //Set Direction
digitalWrite(pinSTEP, HIGH);
delayMicroseconds(2);
digitalWrite(pinSTEP, LOW);
delayMicroseconds(speed_Y);
}
if (joystickValue_Y < Y_THRESHHOLD_LOW) {
    digitalWrite(pinENA,LOW);// enable
    digitalWrite(pinDIR, LOW);  // Other direction
    digitalWrite(pinSTEP,HIGH);
    delayMicroseconds(2);
    digitalWrite(pinSTEP,LOW);
    delayMicroseconds(speed_Y);
  }

  if (joystickValue_Y <=Y_THRESHHOLD_HIGH && joystickValue_Y >= Y_THRESHHOLD_LOW) { 
    digitalWrite(pinENA,HIGH);  // disable the stepper motor if the joystick is in the center
  }
}

I am using an Arduino UNO board with a Sparkfun Joystick Shield connected to a Easy driver board which is going to the bipolar motor.

here is my problem, whenever I press the joystick forward or pull it back the motor only turns counterclockwise. I have tried changing pinDIR from HIGH to LOW and reverse but I am new to this programming. Wanted to understand how to do it myself before I start using libraries.

 centerYValue = abs(centerYValue);//If negative, turns nonnegative

That is where you threw away the information about whether the joystick was pushed forward or back. Perhaps you should take note of the sign of the value BEFORE you destroy it.

Thanks for the advice on that but it still did not help reverse the direction of the motor.

What I am now getting is it still turns in the counter-clockwise direction whenever I press up or down on the joystick BUT instead of going at the same speed when I press up the motor turns fast and press down it slowly turns at more than half the speed

I tried seeing if inserting a negative sign in speed_Y would change the direction

if (joystickValue_Y < Y_THRESHHOLD_LOW) {
    digitalWrite(pinENA,LOW);// enable
    digitalWrite(pinDIR, LOW);  // Other direction
    digitalWrite(pinSTEP,HIGH);
    delayMicroseconds(2);
    digitalWrite(pinSTEP,LOW);
    delayMicroseconds(speed_Y);
  }

so instead of delayMicroseconds(speed_Y); it would be delayMicroseconds(-speed_Y); but all that it did was make it spin at the same speed as pressing up on the joystick

any more thoughts?

Try this:

const int Y_CENTER = 516;  // center position of MY joystick shield
const int Y_DEADBAND = 10;  // Minimum offset required for movement

//Assigning Joystick Shield pins
int pinStickY = 1;

//Assigning Easydriver 
int pinSTEP = 13;       // Step 
int pinDIR  = 12;       // Direction
int pinMS1  = 11;       // MicroStep 1
int pinSLP  = 10;       // Sleep
int pinMS2  =  9;       // MicroStep 2
int pinENA  =  8;       // Enable

void setup() 
{
  pinMode(pinSTEP, OUTPUT);
  pinMode(pinDIR, OUTPUT);
  pinMode(pinENA, OUTPUT);
}

void loop() 
{
  int offset_Y = analogRead(pinStickY) - Y_CENTER; 

  //Set Direction
  digitalWrite(pinDIR, offset_Y < 0);  //  Change to > 0 to swap directions

  offset_Y = abs(offset_Y);

  // If joystick is far enough off center, step the motor
  if (offset_Y > Y_DEADBAND)
  {
    digitalWrite(pinENA, LOW); //Enable
    digitalWrite(pinSTEP, HIGH);
    delayMicroseconds(2);
    digitalWrite(pinSTEP, LOW);
    delayMicroseconds(1000/offset_Y);
  }
  else
  {
    digitalWrite(pinENA,HIGH);  // disable the stepper motor
  }
}

Thank you it worked perfectly! exactly what i needed