speed measurement with 2 ldr sensors help

Hello, can someone please advise?

I am for the school project trying to measure the speed of an object passing between 2 points.
for various reasons in the project have to ldr sensors.

My problem:

In my code 2 millis() of methods work at the same time and provide different starts but only one millis()
include function on ardiuno. Is there any other way I can do the millis transaction? or do I have any idea to solve this problem?

when the purpose is passed from the first sensor, to initiate a different millis() function after passing through the 2nd sensor. In the end to find the difference between them

you can more easily understand what I mean when you look at the code.

materials used in the project:

Arduino Genuino Uno,
2 units ldr sensor,
2 units 10k resistance

Code:

int sensor1Value;
int sensor2Value;
int average_Sensor1;
int average_Sensor2;

double startTime;
double endTime;

double distance = 15; //2 sensors between distance In cm
boolean endFlag;

void setup() {
Serial.begin(9600);
average();
}

void loop() {

//Serial.println(sensor1Value); // Used for determining photoresistor thresholds
//Serial.println(sensor2Value);

Sensor1();
Sensor2();

//MoveTest();

if(endFlag == true && sensor1Value < average_Sensor1 && sensor2Value < average_Sensor2){
Calculate();
}
}

void Sensor1(){
sensor1Value = analogRead(A1);

if(sensor1Value < average_Sensor1){ // If first photoresistor passes threshold, save startTime.
startTime = millis();
endFlag = false;
}
}

void Sensor2(){
sensor2Value = analogRead(A3);

if(sensor2Value < average_Sensor2 && endFlag == false){
endTime = millis();
endFlag = true;
}
}

void Calculate(){

double Time = endTime - startTime;
double TimeInSecond = Time/1000; //millisecond yo second

double Speed = distance/(TimeInSecond);

Serial.print("Speed: “);
Serial.print(Speed);
Serial.println(” cm/s ");

Speed = (Speed*0.036);

Serial.print(“Speed: “);
Serial.print(Speed);
Serial.println(” km/h \n”);

}

void average(){

for(int i=0; i<100; i++){
average_Sensor1 += analogRead(A1);
average_Sensor2 += analogRead(A3);
}
average_Sensor1 = (average_Sensor1/100);
average_Sensor2 = (average_Sensor2/100);

}

  for(int i=0; i<100; i++){
    average_Sensor1 += analogRead(A1);
    average_Sensor2 += analogRead(A3);
  }

100 * 1023 = ?

double startTime;
double endTime;

millis() does not return a double.

for(int i=0; i<100; i++){
average_Sensor1 += analogRead(A1);
average_Sensor2 += analogRead(A3);
}

I do not hang in the part where I got the initial control, it works fine

double startTime;
double endTime;

I forgot to change it I made it for trial. millis() return unsigned long I know.

my problem sensor1() and sensor2 in methods

thanks for your quick response and your interest

I'm not sure I understand your question.
I have only one clock on my kitchen wall, but that doesn't stop me timing different dishes.

Is your (undefined) object really big enough to block both sensors at the same time? That is what the if() in the main loop tests for.

Since the object is currently blocking both sensors, what do you think the time is, which is reported by sensor1?

Use [ code ] tags next time.