Flex Sensor DC Motors sketch

Hi everyone is there anything i could do about all these equal values and make my code shorter ?
also some of the code values seem to be interwined which causes my motor (MOTOR A via Sensor B) and (Motor B via Sensor B) to spin and stop contiunously

here is the code
any help is apreciated

//Motor B
int enableB = 3;
int MotorB1 = 2;
int MotorB2 = 4;
//Motor A
int enableA = 5;
int MotorA1 = 6;
int MotorA2 = 7;

//sensor
int flexValue2;
int flexValue;
const int flexPin2 = A1;
const int flexPin = A0;

//greenpin
const int greenPin = 11;
int ledState = LOW;
unsigned long previousMillis = 0;
const long interval = 1000;

void setup()
{
Serial.begin (9600);
pinMode (enableA, OUTPUT);
pinMode (MotorA1, OUTPUT);
pinMode (MotorA2, OUTPUT);
pinMode (enableB, OUTPUT);
pinMode (MotorB1, OUTPUT);
pinMode (MotorB2, OUTPUT);
pinMode (greenPin, OUTPUT);
}
void loop()
{
{
unsigned long currentMillis = millis();

if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;

// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(greenPin, ledState);
}

{
//enabling motor A Back Sensor
Serial.println (“Enabling MotorsA”);
digitalWrite (enableA, HIGH);
//do something
flexValue = analogRead(flexPin);
delay (0);
Serial.println(flexValue);
Serial.print("sensorB: ");
Serial.println(flexValue);

if (flexValue < 400)
{
Serial.println (“Motion Backwards”);
digitalWrite (MotorA1, HIGH);
digitalWrite (MotorA2, LOW);
}
if (flexValue == 764)
{
Serial.println (“Stoping motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue == 763)
{
Serial.println (“Stoping motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue == 755)
{
Serial.println (“Stoping motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue == 756)
{
Serial.println (“Stoping motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue == 757)
{
Serial.println (“Stoping motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue == 758)
{
Serial.println (“Stoping motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue == 759)
{
Serial.println (“Stoping motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue == 760)
{
Serial.println (“Stoping motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue == 761)
{
Serial.println (“Stoping motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue == 758)
{
Serial.println (“Stoping motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
}
//MOTOR A FRONT SENSOR
{
//enabling motor A
Serial.println (“Enabling MotorsA”);
digitalWrite (enableA, HIGH);
//do something
flexValue2 = analogRead(flexPin2);
delay (0);
Serial.println(flexValue2);
Serial.print("sensorA: ");
Serial.println(flexValue2);

if (flexValue2 > 785)
{
Serial.println (“Motion FORWARD”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, HIGH);
}
if (flexValue2 == 777)
{
Serial.println (“Stop Motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue2 == 774)
{
Serial.println (“Stop Motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue2 == 772)
{
Serial.println (“Stop Motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue2 == 771)
{
Serial.println (“Stop Motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue2 == 773)
{
Serial.println (“Stop Motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue2 == 775)
{
Serial.println (“Stop Motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue2 == 776)
{
Serial.println (“Stop Motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue2 == 778)
{
Serial.println (“Stop Motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue2 == 779)
{
Serial.println (“Stop Motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue2 == 780)
{
Serial.println (“Stop Motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue2 == 781)
{
Serial.println (“Stop Motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
if (flexValue2 == 782)
{
Serial.println (“Stop Motors”);
digitalWrite (MotorA1, LOW);
digitalWrite (MotorA2, LOW);
}
}

{
//TOP Motor
//enabling motor A Back Sensor
Serial.println (“Enabling MotorsB”);
digitalWrite (enableB, HIGH);
//do something
flexValue = analogRead(flexPin);
delay (0);
Serial.println(flexValue);
Serial.print("sensorB: ");
Serial.println(flexValue);
{
if (flexValue < 400)
{
Serial.println (“Motion FORWARD”);
digitalWrite (MotorB1, LOW);
digitalWrite (MotorB2, HIGH);
}
if (flexValue > 550)
{
Serial.println (“Stoping motors”);
digitalWrite (MotorB1, LOW);
digitalWrite (MotorB2, LOW);
}
}
}
}
}

You could certainly use || (logical or) in your ifs when outcomes are the same instead of a long string of separate ifs. E.g.

     if (flexValue2 == 777 || flexValue2 == 774 || flexValue2 == 772 || ... etc )
  {
    Serial.println ("Stop Motors");
    digitalWrite (MotorA1, LOW);
    digitalWrite (MotorA2, LOW);
  }

There are probably more examples. That would be a start in getting the code down to a more manageable size.

Steve