Timer Is stopping all other activty - Help Request (Solved)

I am trying to create a timer that will keep a fan on and leave it on until a 1 minute period has passed, then turn it off.
Once the fan has turn on ,it must stay on for a fixed time of 1 minute before shutting off

I just posted the timer portion, as the full sketch is to large.

The code below works but, while the fan is on and the timer is counting, nothing else is responsive.

What am i doing wrong?

Any help would be appreciated
Thanks
Joe

//*************TIMER CHECK**********************************
//If conditions are true turn on the A3 fan until 1 minute has past then shutoff of A3  are true...

if(rffan == HIGH) // status for temperature sensor 2  (temp2)
{ 
  
  //record start time...
  start_time = millis();
  Serial.println("start_time");
  Serial.println(start_time);

  //turn on A3 fan, turn normal temp led off and high temp led on

  // digitalWrite(A3, HIGH);  // this is the temp2 fan
  digitalWrite(A2,LOW); // BLUE LED off- NORMAL temp
  digitalWrite(9,HIGH); // HIGH TEMP LED

  //Continuosly check for finish time...
  do 
  {

    current_time = millis();
    elapsed_time = current_time - start_time;
    Serial.println("counting");
    Serial.println(elapsed_time);
  }
  while(elapsed_time < 60000); // (1min) * (60s/min) * (1000ms/s)  

}
//turn OFF A3 fan if the count has been met
if (elapsed_time > 60000)
{ 
  digitalWrite(A3, LOW);  // Turn off A3  temp2 fan
}
Serial.println("time complete");
Serial.println(elapsed_time);



// ===========end ===TIMER=================================

Your do/while statement is a redefinition of the delay() function. Of course it stops all other activity.

It’s doing what you told it to:

  do 
  {
    current_time = millis();
    elapsed_time = current_time - start_time;
    Serial.println("counting");
    Serial.println(elapsed_time);
  }
  while(elapsed_time < 60000); // (1min) * (60s/min) * (1000ms/s)

“DO (recalculate elapsed time) UNTIL (elapsed time >= 1 minute)”

What you probably want to do is:
If the fan is ON and elapsed time is >= 1 minute
turn fan off.
do other stuff

This will check elapsed time each time through loop() and turn the fan off at the right time. It doesn’t take long so other stuff gets done.

Thanks for the replies

johnwasser,

Changed the code as per your suggestion / info Works!

  if (rffan == HIGH) // if temp2 went high then rffan is high  over temp occurred - start  counting
 { 
    digitalWrite(9,HIGH); // Turn ON HIGH TEMP ALARM
    //record start time)..
    //start_time = millis();
    current_time = millis();
    elapsed_time = current_time - start_time;
    Serial.println("counting");
    Serial.println(elapsed_time);
    
 }

if ((rffan == HIGH) && (elapsed_time >= 60000)) // fan on and 1 minute check reached?
{
Serial.println("A3FAN OFF"); 
Serial.println(elapsed_time);
digitalWrite(A3, LOW);  // Turn off A3  temp2 fan

rffan =LOW; // reset temp2 status to normal temperature condition
}