running with motor driver and two potentiometers?

Explanation:

Attached is a serial monitor screencap; enA (representing the motor being on or off) is NOT supposed to be 1 if the first potentiometer value (pos value) is over 512.

I don't know if this is because of programming error or strange hardware problem.

I am trying to test the first potentiometer range where if this potentiometer is turned more than halfway, then the motor is supposed to stop and not write anything (enA = 0, etc.).

Expectation:
Basically the rest of the code (besides the debug part) is just supposed to stop and the motor shouldn't turn at all if the first potentiometer is turned more than half way.

If the first potentiometer isn't turned more than halfway, then the rest of the code works where a second potentiometer controls direction. I got this to successfully work earlier and this part is kind of strange too (enA isn't really staying 1 unless the potentiometer is turned to max values), but I am mainly concerned with the first potentiometer.

Unfortunately it seems the motor driver still seems to turn only with 1 potentiometer at a time (for the sake of my goal, shouldn't they override each other with regards to the motor? Because that isn't happening.

Hardware Components:
Arduino Uno R3, Velleman VMA409 L298 Motor Driver, B50K potentiometer, B1k potentiometer

Connections:
Motorshield pin enA to Arduino PWM pin 10
Motorshield pin in1 to Arduino PWM pin 9
Motorshield pin in2 to Arduino pin 8

Arduino analog a5 to first pote middle pin (B50k)
Arduino analog a0 to second pote middle pin (B1k)
Ends of both two potentiometers connected to same the Arduino 5V and Arduino GND

Code:

   int enA = 11;   // Motorshield / Motordriver pin enA to Arduino PWM pin 10, 
   int in1 = 8;  // Motorshield / Motordriver pin in1 to Arduino PWM pin 9
   int in2 = 4;    // Motorshield / Motordriver pin in2 to Arduino pin 8

// First Potentiometer: motor control, direction:

int potePin = A0;
int pote_value = 0;
int pwmOutput = 0;
int pote_value2;
int written;

// Second Potentiometer: feedback

int stop_pote_pin = A5;
int pote_angle_stop_value;

// Far ends of potentiometer are connected to GND, and another to either 3.3V or 5V terminals on Arduino.
// Middle potentiometer pin is connected to A0 (above code)

// Second potentiometer middle pin is connected to A5


// Program variables
int PWM_1_value;
int PWM_2_value;

// int rotDirection;

int DEBUG = 1;

void setup()
{ 
  // Set pins as output:

      pinMode(enA, OUTPUT);
      pinMode(in1, OUTPUT);
      pinMode(in2, OUTPUT);

  // Set initial rotation direction
      digitalWrite(in1, HIGH);
      digitalWrite(in2, LOW);

if (DEBUG)              // "If we want to see the pin values for debugging...
  {
  Serial.begin(9600);   // ...set up the serial ouput in 0004 format"
  } 
}

// Main Program:

void loop ()
{    


    int pote_angle_stop_value = analogRead(stop_pote_pin);     // Read the feedback mechanism
  
    int pote_value = analogRead(potePin);   // Read the potentiometer value at input pin.

    
// Reference code from another example:

  //  int pwmOutput = map(pote_value, 0, 255, 0 , 1023);   // Map the potentiometer value from 0 to 255
  
 // analogWrite(enA, pwmOutput);                         // Send PWM signal to L298N Enable pin

// More reference code:

/*

if (pote_value < 510)    // Lower half of potentiometer's range ( 0 - 512)
    {
  pote_value = (pote_value * 2) / 4;  // "Normalize to 0 to 255".... whatever * timesed equals 1023

  PWM_1_value = 255 - pote_value;    // PWM 1 "from full to off."
  PWM_2_value = 1;                   // PWM 2 "from off to full."
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);

    }

else               // Upper half of potentiometer's range (512 - 1024)
    {
  pote_value = ((pote_value - 514) * 2) / 4; // "Normalize to 0-255"
  PWM_1_value = 1;
  PWM_2_value = pote_value;
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
    }


*/
// Program loops:

while (stop_pote_pin > 510)
{
analogWrite(enA, 0);
break;
}


if (stop_pote_pin < 510)
{              
                   
while (pote_value < 510)    // Lower half of potentiometer's range ( 0 - 512)
    {
  pote_value2 = (pote_value * 2) / 4;  // "Normalize to 0 to 255".... whatever * timesed equals 1023
  
/*
written =255 - potevalue2;
*/
// OR:
written = 255 - pote_value2;    // PWM "from full to off."
    
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  analogWrite(enA, written); 
  break;
  
    }

while (pote_value > 510)               // Upper half of potentiometer's range (512 - 1024)
    {
  pote_value2 = ((pote_value - 512) * 2) / 4; // "Normalize to 0-255"
  
  written = pote_value2;

  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  analogWrite(enA, written); 

  
  
  break;
   
    }
}


// Debug part:

  // For further debugging:
  int enA_value = digitalRead(enA);
  int in1_value = digitalRead(in1);
  int in2_value = digitalRead(in2);

if (DEBUG)              // "If we want to read the output"
  {
    DEBUG += 1;          // "Increment the DEBUG counter"
    
    if (DEBUG > 100)     // "Print every hundred loops"
     {
      DEBUG = 1;        // "Reset the counter"

// "Serial output using 0004-style functions:"
      Serial.print("Pote Pos.: ");
      Serial.print(pote_angle_stop_value);
      Serial.print("\t");
      Serial.print("\t");

      Serial.print("Pot2: ");
      Serial.print(pote_value);
      Serial.print("\t");   

      Serial.print("edited pot value: ");
      Serial.print(pote_value2);
      Serial.print("\t");


      Serial.print("Written PWM Output: ");
      Serial.print(written);
      Serial.print("\t");   

      Serial.print("enA: ");      // Indicate output is in1 value
      Serial.print(enA_value);          // Print in1 value
      Serial.print("\t");  

      Serial.print("in1: ");      // Indicate output is in1 value
      Serial.print(in1_value);          // Print in1 value
      Serial.print("\t");  

      Serial.print("in2: ");      // Indicate output is in1 value
      Serial.print(in2_value);          // Print in2 value
      Serial.print("\t");  

      Serial.print("\n");
      Serial.print("\n");
    
    delay(10);
    }
  }
}

Goal: This is all supposed to be for simulation purposes

int stop_pote_pin = A5;
  while (stop_pote_pin > 510)

stop_pote_pin is a pin number. It will never be greater than 510