Problem with the Line follower

I have made a line follower using 5 IR sensors using analog pin. I am using pid algo for control of the bot.
Problem that i am facing is that while using L293D for motor control with 12v the motor is not working properly.
I have made the motor connections as per the image…

I have used the following code

long sensors_average;
int sensors_sum;
int position;
int proportional,integral,derivative;
int Kp=4;
int Ki=0.2;
int Kd=1;
int error_value,last_proportional;
int set_point=1998;
long sensors[] = {0, 0, 0, 0, 0}; // Array used to store 5 readings for 5 sensors
int motor_left[]={2,4};
int motor_right[]={7,8};
void setup()
{ Serial.begin(9600);
// Setup motors
int i;
for(i = 0; i < 2; i++){
pinMode(motor_left[i], OUTPUT);
pinMode(motor_right[i], OUTPUT);
}
}
void loop()
{ sensors_average = 0;
sensors_sum = 0;
for (int i = 0; i < 5; i++)
{sensors[i] = analogRead(i);
sensors_average += sensors[i] * i * 1000; //Calculating the weighted mean
sensors_sum += int(sensors[i]);} //Calculating sum of sensor readings
pid_calc();
Serial.println();
turn_calc();

delay(500);
}
void pid_calc()
{ position = int(sensors_average / sensors_sum);

proportional=set_point-position;
integral = integral + proportional;
derivative = proportional - last_proportional;
last_proportional = proportional;
error_value = int(proportional * Kp + integral * Ki + derivative * Kd);
Serial.print(error_value);
Serial.print(' ');

}
// restrict error value to +-255.00  
void turn_calc() {
  if (error_value<-255) {
  
   
    turn_right();
  
  }
  
  if (error_value>-50 and error_value<50) {
    
    drive_forward();

  
  }
  if (error_value>255) {
    
    turn_left();
  
  }
 
}


  

// ————————————————————————— Drive

void motor_stop(){
digitalWrite(motor_left[0], LOW);
digitalWrite(motor_left[1], LOW);

digitalWrite(motor_right[0], LOW);
digitalWrite(motor_right[1], LOW);
delay(25);
}

void drive_forward(){
digitalWrite(motor_left[0], HIGH);
digitalWrite(motor_left[1], LOW);

digitalWrite(motor_right[0], HIGH);
digitalWrite(motor_right[1], LOW);
Serial.print('2');
Serial.print(' ');
}

void drive_backward(){
digitalWrite(motor_left[0], LOW);
digitalWrite(motor_left[1], HIGH);

digitalWrite(motor_right[0], LOW);
digitalWrite(motor_right[1], HIGH);
Serial.print('4');
Serial.print(' ');
}

void turn_left(){
digitalWrite(motor_left[0], LOW);
digitalWrite(motor_left[1], HIGH);

digitalWrite(motor_right[0], HIGH);
digitalWrite(motor_right[1], LOW);
Serial.print('1');
Serial.print(' ');
}

void turn_right(){
digitalWrite(motor_left[0], HIGH);
digitalWrite(motor_left[1], LOW);

digitalWrite(motor_right[0], LOW);
digitalWrite(motor_right[1], HIGH);
Serial.print('3');
Serial.print(' ');
}

Pls help ASAP!!!

Moderator edit: I swear, I’m going to start just deleting posts that should use CODE TAGS but don’t.

Untitled.png

What your are doing wrong is the process of robot building! You need to do one thing at a time! Test each part by itself until we know what to target. Start with making your robot move forward. If it does not move then we can deal with that problem. If it does work well test each light sensor using serial monitor. I (or anybody on this form) will not even start to look at your code until you have tested everything to see where the problem is.

Also photos of the Arduino would help! Hopefully you have the inputs connected to the Arduino from the motor driver.

Thank you for this input I shall test each part of the code and then post here if there is any problem with my test scenario..