code helping with arduino and two ultrasonics

Hi everybody..

I'm working on a project which consists of two ultrasonics, LCD and Arduino.

As you know ultrasonic is also used to measure flow rate of water according to the following concept

http://www.universalmetering.co.uk/images/mobile/ultrasonic-diagram.gif

the concept behind that is to send waves from first ultrasonic to the second, calculate the time1. next, send waves from the second which will be received by the first and calculate time2.

time1 must equal time2 if there is no flow. but I'm not sure that my arduino code is correct because it is not showing me the true results.

could you please check it and if you have the correct code give it..

thanks..

LiquidCrystal LCD(11,10,9,2,3,4,5); 
//Create Liquid Crystal Object called LCD 
#define trigPin1 13 //Sensor Echo pin connected to Arduino pin 13
#define echoPin1 12 //Sensor Trip pin connected to Arduino pin 12 
#define trigPin2 7 //Sensor Echo pin connected to Arduino pin 7
#define echoPin2 8 //Sensor Trip pin connected to Arduino pin 8 
//Simple program just for testing the HC-SR04 Ultrasonic Sensor with LCD dispaly //URL: 

void setup()
{ 
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);
  LCD.begin(16,2); 
  //Tell Arduino to start your 16 column 2 row LCD 
  LCD.setCursor(0,0); //Set LCD cursor to upper left corner, column 0, row 0
  LCD.print("Difference in time:"); //Print Message on First Row 
  
 }

  
  void loop() 
  { 
    long duration1, duration2, diff=0;
   
    digitalWrite(trigPin1, LOW);
    delayMicroseconds(2); 
    digitalWrite(trigPin1, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin1, LOW); 
    duration1 = pulseIn(echoPin2, HIGH);
    
   digitalWrite(trigPin2, LOW);
    delayMicroseconds(2); 
    digitalWrite(trigPin2, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin2, LOW);
    duration2 = pulseIn(echoPin1, HIGH);
    
    diff = (duration2) - (duration1);
    LCD.setCursor(0,1); //Set cursor to first column of second row 
    LCD.print(" "); //Print blanks to clear the row
    LCD.setCursor(0,1); //Set Cursor again to first column of second row
    LCD.print(diff); //Print measured distance 
    LCD.print(" sec"); //Print your units.
    delay(250); //pause to let things settle
    
    }

I'd be very wary of triggering two pings so close to each other; how do you know the return pulse received for the second ping isn't just a distant echo of the first?

What happens when you print the individual durations, not simply their difference?

    diff = (duration2) - (duration1);

(why) all (the brackets) ?

I would think that there isn't enough distance between the two ultrasonic transducers to give a result. I think the closest reading in air was 4 or 5 inches, from transmitter to object and back, so for one way 8 to 10 inches. And, since the speed of sound in water is 4.3 times faster than in air, so the minimum separation becomes 34 to 43 inches.