Adding a sensor slows down the operation

Hey. Im doing a obstacle avoiding robot. Everything is going fine while I use two front sensors, but when I add one to the back, the reading of the sensors slows down the reading of the sensors and the robot crashes before it reads the distance.
Theres also a LCD screen with a temperature sensor connected. L is for Left, R- right, and B-back sensor.
The idea is to make it go backwards and turn if theres no obstacle behind it. If there is, just turn instantly.
This is clearly not the best way to do it, but this is how i got it working and it all works, just too slow with the third sensor.
P.S.: Theres a bluetooth connection.

#include <SoftwareSerial.h>
#include <Wire.h>
#include <hd44780_I2Cexp.h>
#include <DHT.h>
#include <Adafruit_Sensor.h>
#include <DHT_U.H>
hd44780_I2Cexp lcd;
SoftwareSerial BT(5,6); 

#define trigPinL 2 
#define echoPinL 7
#define trigPinR 10// 
#define echoPinR 4
#define trigPinB 5 // 
#define echoPinB 6

#define LeftMotor 12 
#define RightMotor 13 

#define LeftBrakes 9 
#define RightBrakes 8 

#define LeftSpeed 3 
#define RightSpeed 11 

#define DHTPIN A3
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

 const int ROWS = 2;
 const int COLS = 16;
 int chk;
 float temp;
void setup() {
  Serial.begin(9600); // begin serial communitication  
  Serial.println("Motor test!");

  dht.begin();
  
  pinMode(trigPinL, OUTPUT);
  pinMode(echoPinL, INPUT);

  pinMode(trigPinR, OUTPUT);
  pinMode(echoPinR, INPUT);

  pinMode(LeftMotor, OUTPUT);
  pinMode(RightMotor, OUTPUT);

  pinMode(LeftBrakes, OUTPUT);
  pinMode(RightBrakes, OUTPUT);
  
  digitalWrite(LeftBrakes, LOW);
  digitalWrite(RightBrakes, LOW); 

 
  BT.begin(9600);

  lcd.begin(COLS,ROWS);

 
 
}
 char a;
void loop() 
{  

 if (BT.available())

{
  a=(BT.read());
}
  
  if (a=='F') 
  {

   digitalWrite(LeftBrakes, LOW);  
   digitalWrite(RightBrakes, LOW); 
   
   digitalWrite(LeftMotor, HIGH);
   analogWrite(LeftSpeed, 120);

   digitalWrite(RightMotor, HIGH);
   analogWrite(RightSpeed, 120);

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Command:");
      lcd.setCursor(0,1);
      lcd.print("Forward ");
  }

  if (a=='S')
  {
    digitalWrite(LeftBrakes, HIGH); 
    digitalWrite(RightBrakes, HIGH); 
   
   analogWrite(LeftSpeed, 0);
   analogWrite(RightSpeed, 0);

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Command:");
      lcd.setCursor(0,1);
      lcd.print("STOP ");
  }

  if (a=='L') 
  {
    digitalWrite(LeftBrakes, LOW); 
    digitalWrite(RightBrakes, LOW); 
    
    digitalWrite(LeftMotor, HIGH); 
    analogWrite(LeftSpeed, 120);

    digitalWrite(RightMotor, LOW);
    analogWrite(RightSpeed, 120);

  }

  if(a=='R')
  {

    digitalWrite(LeftBrakes, LOW); 
    digitalWrite(RightBrakes, LOW); 
    
    digitalWrite(LeftMotor, LOW); 
    analogWrite(LeftSpeed, 120);

    digitalWrite(RightMotor, HIGH);
    analogWrite(RightSpeed, 120);
  }

  if(a=='B') 
  {

    digitalWrite(LeftBrakes, LOW); 
    digitalWrite(RightBrakes, LOW); 
    
   digitalWrite(LeftMotor, LOW);
   analogWrite(LeftSpeed, 120);

   digitalWrite(RightMotor, LOW);
   analogWrite(RightSpeed, 120);
  }


  if(a=='C') 
{
    digitalWrite(LeftBrakes, LOW); 
    digitalWrite(RightBrakes, LOW); 

  // start the scan
long durationL, distanceL;
     
  digitalWrite(trigPinL, LOW);  
  delayMicroseconds(2); // delays are required for a succesful sensor operation.
  digitalWrite(trigPinL, HIGH);
  delayMicroseconds(10); //this delay is required as well!
  digitalWrite(trigPinL, LOW);
  durationL = pulseIn(echoPinL, HIGH);
  distanceL = (durationL/2) / 29.1;// convert the distance to centimeters.
 long durationR, distanceR;
  
  digitalWrite(trigPinR, LOW);  
  delayMicroseconds(2); // delays are required for a succesful sensor operation.
  digitalWrite(trigPinR, HIGH);
  delayMicroseconds(10); //this delay is required as well!
  digitalWrite(trigPinR, LOW);
  durationR = pulseIn(echoPinR, HIGH);
  distanceR = (durationR/2) / 29.1;// convert the distance to centimeters

long durationB, distanceB;
 digitalWrite(trigPinB, LOW);  
  delayMicroseconds(2); // delays are required for a succesful sensor operation.
  digitalWrite(trigPinB, HIGH);
  delayMicroseconds(10); //this delay is required as well!
  digitalWrite(trigPinB, LOW);
  durationB = pulseIn(echoPinB, HIGH);
  distanceB = (durationB/2) / 29.1;// convert the distance to centimeters */
   
  temp = dht.readTemperature();
  
  
  
  if (distanceL > 25 && distanceR > 25)
  {
   
   
   digitalWrite(LeftMotor, HIGH);
   analogWrite(LeftSpeed, 120);

   digitalWrite(RightMotor, HIGH);
   analogWrite(RightSpeed, 120);

   lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Atstumas");
  lcd.setCursor(12,0);
  lcd.print(distanceR);
  lcd.print("cm");
  lcd.setCursor(0,1);
  lcd.print("Temperatura");
  lcd.setCursor(12,1);
  lcd.print(temp);
  lcd.print("C");
      
  }

  else if (distanceL > 25 && distanceR < 25 && distanceR > 15)
  {
     
      lcd.clear();
      lcd.setCursor(3,0);
      lcd.print("(O_O)");
      lcd.setCursor(0,1);
      lcd.print("DANGER RIGHT ");
    
    digitalWrite(LeftMotor, LOW); 
    analogWrite(LeftSpeed, 120);

    digitalWrite(RightMotor, HIGH);
    analogWrite(RightSpeed, 120);
      
  }

  else if (distanceL < 25 && distanceL > 15 && distanceR > 25)
  {
      
      lcd.clear();
      lcd.setCursor(3,0);
      lcd.print("(O_O)");
      lcd.setCursor(0,1);
      lcd.print("DANGER LEFT");
    
    digitalWrite(LeftMotor, HIGH); 
    analogWrite(LeftSpeed, 120);

    digitalWrite(RightMotor, LOW);
    analogWrite(RightSpeed, 120);

      
  }

  else if (distanceL < 15 && distanceR < 15 && distanceB > 15  ) 
  {
      
      lcd.clear();
      lcd.setCursor(3,0);
      lcd.print("(O_O)");
      lcd.setCursor(0,1);
      lcd.print("DANGER AHEAD ");
    
   digitalWrite(LeftMotor, LOW);
   analogWrite(LeftSpeed, 120);

   digitalWrite(RightMotor, LOW);
   analogWrite(RightSpeed, 120);

   delay(100);
    digitalWrite(LeftMotor, HIGH); 
    analogWrite(LeftSpeed, 120);

    digitalWrite(RightMotor, LOW);
    analogWrite(RightSpeed, 120);
   
  }
  else if (distanceL < 15 && distanceR < 15 && distanceB <15 )
  {
      lcd.clear();
      lcd.setCursor(3,0);
      lcd.print("(O_O)");
      lcd.setCursor(0,1);
      lcd.print("DANGER AHEAD ");

    digitalWrite(LeftMotor, HIGH); 
    analogWrite(LeftSpeed, 120);

    digitalWrite(RightMotor, LOW);
    analogWrite(RightSpeed, 120);
  }
  
}
}

the reading of the sensors slows down the reading of the sensors

Say what? Some clarification is definitely in order.

  a=(BT.read());

(What's) (with) (the) (useless) (parentheses) (?)

If all three sensors are wired the same, reading three will only take 50% longer than reading two.

I can not imagine why your robot is carrying a temperature sensor.

Whoops. Got lost in my own thougths there. What i meant to say, that with the 3 sensors it takes longer to read the information and the robot actually hits the obstacle before the sensors realise that they should act.

To explain the temperature sensor, i got it with the LCD, so I was trying it out.
So theres no way to make it faster? Or i should remove the temperature sensor?

What i meant to say, that with the 3 sensors it takes longer to read the information

About 50% longer. So, either slow down, or set a danger distance that is larger, so you have more time to read.

So theres no way to make it faster?

The NewPing library uses interrupts rather than the "stick your head in the sand until the echo comes back" pulseIn() method, so it can be faster. But, using it requires a completely different mindset, where you use the last data obtained, rather than the next data.

Im trying the NewPing library, but have no clue how to get it working as id like to. I saw tutorials on multiple sensors but cant find or figure out how to do “if” statments with the data I have.

#include <NewPing.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <hd44780_I2Cexp.h>
#include <DHT.h>
#include <Adafruit_Sensor.h>
#include <DHT_U.H>
hd44780_I2Cexp lcd;
SoftwareSerial BT(5,6); 


#define sensors 3
#define maxdistance 200
#define interval 33
unsigned long pingTimer[sensors]; 
unsigned int cm[sensors];
uint8_t currentSensor = 0;
/*#define trigPinL 2 
#define echoPinL 7
#define trigPinR 10// 
#define echoPinR 4
#define trigPinB 5 // 
#define echoPinB 6
*/
#define LeftMotor 12 
#define RightMotor 13 

#define LeftBrakes 9 
#define RightBrakes 8 

#define LeftSpeed 3 
#define RightSpeed 11 

#define DHTPIN A3
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);
NewPing sonar[sensors] = {
NewPing(2,7, 300),
NewPing(10,4, 300),
NewPing(15,16, 300),
};



 const int ROWS = 2;
 const int COLS = 16;
 int chk;
 float temp;
void setup() {
  Serial.begin(9600); // begin serial communitication  
  Serial.println("Motor test!");

  dht.begin();
  
 // pinMode(trigPinL, OUTPUT);
  //pinMode(echoPinL, INPUT);

  //pinMode(trigPinR, OUTPUT);
  //pinMode(echoPinR, INPUT);
pingTimer[0] = millis() + 75;           // First ping starts at 75ms, gives time for the  Arduino to chill before starting.
 for (uint8_t i = 1; i < sensors; i++) // Set the starting time for each sensor.
      pingTimer[i] = pingTimer[i - 1] + interval;
      
  pinMode(LeftMotor, OUTPUT);
  pinMode(RightMotor, OUTPUT);

  pinMode(LeftBrakes, OUTPUT);
  pinMode(RightBrakes, OUTPUT);
  
  digitalWrite(LeftBrakes, LOW);
  digitalWrite(RightBrakes, LOW); 

 
  BT.begin(9600);

  lcd.begin(COLS,ROWS);

  

 
 
}
 char a;
 
void loop() {
  for (uint8_t i = 0; i < sensors; i++) { // Loop through all the sensors.
    if (millis() >= pingTimer[i]) {         // Is it this sensor's time to ping?
      pingTimer[i] += interval * sensors;  // Set next time this sensor will be pinged.
      if (i == 0 && currentSensor == sensors - 1) oneSensorCycle(); // Sensor ping cycle complete, do something with the results.
      sonar[currentSensor].timer_stop();          // Make sure previous timer is canceled before starting a new ping (insurance).
      currentSensor = i;                          // Sensor being accessed.
      cm[currentSensor] = 0;                      // Make distance zero in case there's no ping echo for this sensor.
      sonar[currentSensor].ping_timer(echoCheck); // Do the ping (processing continues, interrupt will call echoCheck to look for echo).
    }
  }
  //  if (BT.available())

{
  a=(BT.read());
}
  
  if (a=='F') 
  {

   digitalWrite(LeftBrakes, LOW);  
   digitalWrite(RightBrakes, LOW); 
   
   digitalWrite(LeftMotor, HIGH);
   analogWrite(LeftSpeed, 120);

   digitalWrite(RightMotor, HIGH);
   analogWrite(RightSpeed, 120);

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Command:");
      lcd.setCursor(0,1);
      lcd.print("Forward ");
  }

  if (a=='S')
  {
    digitalWrite(LeftBrakes, HIGH); 
    digitalWrite(RightBrakes, HIGH); 
   
   analogWrite(LeftSpeed, 0);
   analogWrite(RightSpeed, 0);

      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Command:");
      lcd.setCursor(0,1);
      lcd.print("STOP ");
  }

  if (a=='L') 
  {
    digitalWrite(LeftBrakes, LOW); 
    digitalWrite(RightBrakes, LOW); 
    
    digitalWrite(LeftMotor, HIGH); 
    analogWrite(LeftSpeed, 120);

    digitalWrite(RightMotor, LOW);
    analogWrite(RightSpeed, 120);

  }

  if(a=='R')
  {

    digitalWrite(LeftBrakes, LOW); 
    digitalWrite(RightBrakes, LOW); 
    
    digitalWrite(LeftMotor, LOW); 
    analogWrite(LeftSpeed, 120);

    digitalWrite(RightMotor, HIGH);
    analogWrite(RightSpeed, 120);
  }

  if(a=='B') 
  {

    digitalWrite(LeftBrakes, LOW); 
    digitalWrite(RightBrakes, LOW); 
    
   digitalWrite(LeftMotor, LOW);
   analogWrite(LeftSpeed, 120);

   digitalWrite(RightMotor, LOW);
   analogWrite(RightSpeed, 120);
  }


  if(a=='C') 
{
    digitalWrite(LeftBrakes, LOW); 
    digitalWrite(RightBrakes, LOW); 

  // start the scan
 
  temp = dht.readTemperature();
  
  
  
  if (cm[1] > 20 && cm[2] > 20)
  {
   
   
   digitalWrite(LeftMotor, HIGH);
   analogWrite(LeftSpeed, 120);

   digitalWrite(RightMotor, HIGH);
   analogWrite(RightSpeed, 120);

   lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Atstumas");
  lcd.setCursor(12,0);
  lcd.print(cm[1]);
  lcd.print("cm");
  lcd.setCursor(0,1);
  lcd.print("Temperatura");
  lcd.setCursor(12,1);
  lcd.print(temp);
  lcd.print("C");
      
  }

  else if (cm[2] > 20 && cm[2] < 15 && cm[2]> 20)
  {
     
      lcd.clear();
      lcd.setCursor(3,0);
      lcd.print("(O_O)");
      lcd.setCursor(0,1);
      lcd.print("DANGER RIGHT ");
    
    digitalWrite(LeftMotor, LOW); 
    analogWrite(LeftSpeed, 120);

    digitalWrite(RightMotor, HIGH);
    analogWrite(RightSpeed, 120);
      
  }

  else if (cm[1] < 20 && cm[1] > 15 && cm[2] > 20)
  {
      
      lcd.clear();
      lcd.setCursor(3,0);
      lcd.print("(O_O)");
      lcd.setCursor(0,1);
      lcd.print("DANGER LEFT");
    
    digitalWrite(LeftMotor, HIGH); 
    analogWrite(LeftSpeed, 120);

    digitalWrite(RightMotor, LOW);
    analogWrite(RightSpeed, 120);

      
  }

  else if (cm[1] < 20 && cm[2] < 20 && cm[3] > 20) 
  {
      
      lcd.clear();
      lcd.setCursor(3,0);
      lcd.print("(O_O)");
      lcd.setCursor(0,1);
      lcd.print("DANGER AHEAD ");
    
   digitalWrite(LeftMotor, LOW);
   analogWrite(LeftSpeed, 120);

   digitalWrite(RightMotor, LOW);
   analogWrite(RightSpeed, 120);

   delay(100);
    digitalWrite(LeftMotor, HIGH); 
    analogWrite(LeftSpeed, 120);

    digitalWrite(RightMotor, LOW);
    analogWrite(RightSpeed, 120);
   
  }
  else if (cm[1] < 20 && cm[2] < 20 && cm[3] <20 )
  {
      lcd.clear();
      lcd.setCursor(3,0);
      lcd.print("(O_O)");
      lcd.setCursor(0,1);
      lcd.print("DANGER AHEAD ");

    digitalWrite(LeftMotor, HIGH); 
    analogWrite(LeftSpeed, 120);

    digitalWrite(RightMotor, LOW);
    analogWrite(RightSpeed, 120);
  }
  
} 
 
}



void echoCheck() { // If ping received, set the sensor distance to array.
 if (sonar[currentSensor].check_timer())
  cm[currentSensor] = sonar[currentSensor].ping_result / US_ROUNDTRIP_CM;
 }

void oneSensorCycle() 
{ // Sensor ping cycle complete, do something with the results.

 for (uint8_t i = 0; i < sensors; i++) {
  Serial.print(i);
  Serial.print("=");
  Serial.print(cm[i]);
  Serial.print("cm ");

 }
 }

The bluetooth most likely will not work either here, right?

You have an array with three distance values in it, in positions 0, 1, and 2, not 1, 2, and 3.