Need some help coding for a photo interrupter & motor

OK I know this one should be pretty easy, but for some reason my brain isn't working anymore these days.
Here's what I'n trying to code.
The motor turns on & stays on until the photo interrupter beam is blocked.
The motor then turns off & a timer starts.
When the timer is done the motor starts up again.
I can get this all to work, but my problem is when the motor starts up again the photo interrupter beam is still blocked, so it wants to turn the motor off again.

Any suggestions on how to get this to work? Maybe an example or pseudo code...

set interval
set done to false
start motor

start of loop
  if beam is interrupted and done is false
    stop motor
    set done to true
    set start time to millis()
   end if
   
   if millis - start time >= interval
     start motor
   end if
end of loop

Thanks for the help, I think I almost got it, but the "startMotor()" keeps looping over & over..

boolean done = false;
int interval = 10000;
int photoBeam = 0; 
unsigned long startTime;

void setup() {
  startMotor();
}

void loop() {
  photoBeam = digitalRead(photoInt);  
  // val == HIGH, photo beam not blocked
  // val == LOW, photo beam blocked
  
  if ((photoBeam == LOW) && (done == false)){
    stopMotor();
    done = true;
    startTime = millis();
  }  
  
  if ((millis() - startTime) >= interval)
  {
     startMotor();  //loops here.
  }
}

If calling startMotor() more than once is a problem then you can test the boolean variable before calling it. It would be better to name the variable motorRunning to make its meaning more obvious.

boolean motorRunning;
unsigned long interval = 10000;
int photoBeam = 0; 
unsigned long stopTime;

void setup() 
{
  startMotor();
  motorRunning = true;
}

void loop() 
{
  photoBeam = digitalRead(photoInt);  
  // val == HIGH, photo beam not blocked
  // val == LOW, photo beam blocked

  if ((photoBeam == LOW) && (motorRunning == true))
  {
    stopMotor();
    motorRunning = false;
    stopTime = millis();
  }  

  if (((millis() - stopTime) >= interval) && (motorRunning == false))
  {
    startMotor();
    motorRunning = true;
  }
}

Note that interval should be an unsigned long as in the code above

Thanks again, but no that doesn't work. I'm back to where I was having trouble originally.

The timer ends the motor starts up & the loops starts over.
But it hasn't moved out of the photo beam yet, so photoBeam is still LOW & motorRunning is true, so it stops the motor right away again...

I think we where closer with the first version...

OK I think I finally got it to work. Let me know if you seen any major errors...

const int photoInt =  10;

boolean motorRunning;
boolean inBeam;
boolean old_inBeam;
unsigned long interval = 10000;
int photoBeam = 0; 
unsigned long stopTime;

void setup() {
  startMotor();
  motorRunning = true;
}

void loop() 
{
  photoBeam = digitalRead(photoInt);  
  // val == HIGH, photo beam not blocked
  // val == LOW, photo beam blocked

  if (photoBeam == LOW)
  {
    inBeam = true;
  } else {
    inBeam = false;
  }
  
  // check if we transitioned from not inBeam to inBeam
  if ((inBeam == true) && (old_inBeam == false)){
    stopMotor();
    motorRunning = false;
    stopTime = millis();
  }
  
  old_inBeam = inBeam; // inBeam is now old, let's store it

  if (((millis() - stopTime) >= interval) && (motorRunning == false))
  {
    startMotor();
    motorRunning = true;
  }
}

Thanks again for the help UKHeliBob, I'd still be stuck without your input.

Looks OK. When I read your previous reply it occurred to me that what was required was state change detection rather than just detection of the current state, which is what you you have done.

Good luck with the project as it progresses.