3 ultrasonic sensors, only 1 works properly.

Hey, in my project i'm using 3 ultrasonic sensors, 1 stand in the forward, and the other two are on the sides (1 left 1 right).
I added a serial to test how the sensors are working. I found out only the right one wors properly, the others just give me a 0. the electrical stuffs are a 100% fine. I'm very confused at this point lol

here's the code:

int TpinF=2;
int EpinF=3;
int TpinL=4;
int EpinL=5;
int TpinR=6;
int EpinR=7;
volatile long TF=0;
volatile long TL=0;
volatile long TR=0;
volatile int DF=0;
volatile int DL=0;
volatile int DR=0;

void setup() {
// put your setup code here, to run once:
pinMode(TpinF, OUTPUT);
pinMode(EpinF, INPUT);

pinMode(TpinL, OUTPUT);
pinMode(EpinL, INPUT);

pinMode(TpinR, OUTPUT);
pinMode(EpinR, INPUT);

Serial.begin (9600);

}

void loop() {

digitalWrite(TpinL, LOW);
delayMicroseconds(5);
digitalWrite(TpinL,HIGH);
delayMicroseconds(10);
digitalWrite(TpinF, LOW);
pinMode(EpinL, INPUT);
TL = pulseIn(EpinL, HIGH);
delay(10);

digitalWrite(TpinR, LOW);
delayMicroseconds(5);
digitalWrite(TpinR, HIGH);
delayMicroseconds(10);
digitalWrite(TpinR, LOW);
pinMode(EpinR, INPUT);
TR = pulseIn(EpinR, HIGH);
delay(10);

digitalWrite(TpinF, LOW);
delayMicroseconds(5);
digitalWrite(TpinF, HIGH);
delayMicroseconds(10);
digitalWrite(TpinF, LOW);
pinMode(EpinF, INPUT);
TF = pulseIn(EpinF, HIGH);
delay(10);

DF = TF0.034/2;
DL = TL
0.034/2;
DR = TR*0.034/2;

Serial.print(DF);
Serial.print("DF, \n");
Serial.print(DL);
Serial.print("DL, \n");
Serial.print(DR);
Serial.print("DR, \n");

}

I'm pretty sure i'm missing something VERY obvious.

BTW, the sensors worked just like that like a week ago. they calculated the distances right and corresponded with the rest of the project. now they wouldn't even work on their own :frowning: I've only changed the code a bit since they last worked.. not sure what I did wrong with it.

Your third call to digitalWrite() in loop() has the wrong pin.

Also 10ms is not very long to wait for a ping to die down in a room. Try 100 ms

Post code between code [/] tags.
No need to make variables volatile.
No need to set the pinMode of the echo pins to INPUT time and again.
Add a timeout to the pulseIn() function, 30000 µs is long enough to wait. Then our time variables can also become int or unsigned int type, smaller than long.
Make your pins a const byte rather than const int.
Put your calls in functions, makes your code more maintainable and prevent errors like the wrong pin number:

void loop() {
  TF = getMeasurement(TpinF, EpinF);
  delay(100);
  TL = getMeasurement(TpinL, EpinL);
  delay(100);
  TR = getMeasurement(TpinR, EpinR);

  // Rest of your code.
}

unsigned int getMeasurement (byte trig, byte echo) {
  digitalWrite(trig, LOW); 
  delayMicroseconds(5);                     
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);     
  digitalWrite(trig, LOW); 
  return pulseIn(echo, HIGH, 30000); 
}