LDR Timer resetting NEED help!!!

Having issue with ldrPin1 (A0) resets timer and starts new time. Need to have total recorded time from the initial start. Need help with a solution to put ldrPin1 in some sort of delay or sleep state so it will not reset the timer on the second pass. I have uploaded a video on yt, can be seen at: Arduino LDR timer issues.

I uploaded the video for those who need visual reference like myself. The code is below hopefully someone can help me finish this project. Thank you in advance

You need to write out all the states, something like:

before LDR1
after LDR1 before LDR2
after LDR2 before LDR2 return
after LDR2 return before LDR1 return
after LDR1 return (same as first state).

Each transition should record its time and compare with previous transition to get timings and to check
the states haven't got confused - at each point you expect a particular LDR next - check that is what happens,
and that the delay since the last change is sensible. Try to resync states if something different happens, but
log the problem with a Serial print too.

Ok, thanks. That gives me a couple ideas that popped into my head, not sure if they will work but will give it a go. Again thanks for the advice.

Ok I posted the video on you tube, I have found that through visualization things become more clear. I hope I get some answers on how to solve this issue. The video can be seen at

Again thanks in advance for all the help and advice...

/* Object starts a pendulum swing between ldrPin1 and ldrPin2 going from
   right to left. Total recorded time from start to finish
*/

const int THRESHOLD_LOW = 650; // Threshold of amount of light in area, can be adjusted to fit lighting conditions
const int THRESHOLD_HIGH = 700; // Same as above
int ldrPin1 = A0; // object swings right, shadow passes over LDR starting timer
int ldrPin2 = A5; // object swings left, shadow passes over LDR stopping timer
int HystereticRead (int pin, int previousState) {

  int photo = analogRead (pin);
  if (previousState == LOW && photo >= THRESHOLD_HIGH) {
    return HIGH;
  }
  else if (previousState == HIGH && photo < THRESHOLD_LOW) {
    return LOW;
  }
  else {
    return previousState;
  }
}
void setup() {
  Serial.begin (9600);
}
void loop() {
  static int state0, state1;
  static double time0, time1, time2;

  int  new_state = HystereticRead (A0, state0);
  if (state0 == LOW && new_state == HIGH) {

    time0 = millis ();

  }
  state0 = new_state;

  new_state = HystereticRead (A5, state1);
  if (state1 == LOW && new_state == HIGH) {
    time1 = millis ();
    time2 = (time1 - time0) / 1000;

    Serial.println ("time passed: (s)");
    Serial.println (time2);
  }
  state1 = new_state;
}

Here is the link to my video of what my project is, what I want to accomplish and what is wrong with my code