Continuing the main program after a loop...

Hello,
I am basically trying to code a program that will run the loop for a while and then come back to main program. What I want to do is: There is a task that I need to perform. Almost every step is going to be executed once except a period where a stepper motor needs to power a rocking platform for 5 minutes, while a temperature sensor controls the temperature of the surface and sends the information back to the silicone heater that I am controlling via a mosfet that will keep my cell culture at 37 degrees Celcius. So my question is how can I run this loop for 5 min and continue on my void (setup); program.

So it will be like this

#Libraries stepper, temp sensor, servo, led, etc

void(setup);
my program will run once
void (loop);
the function that I described above will run for 5 minutes
and I want to go back to my main program to finish up the tasks that will be completed just once.

Thank you,

The setup() is to initialize pins and initialize or create objects and start the serial communication and so on.
If you want to run some code again, then you have to put it in loop().
For the 5 minutes, you could use a delay() or the function millis().

Newbie here too...but:

I don't think you can go back to the void(setup);.

I think you might need to put a "copy" in the void(loop); Then use an "if else" to skip it or run it depending on what you want it to do.

Read this: Several Things at the Same Time. Think about your problem some more. Try to apply that technique to a small part of your problem. Eventually you will understand and you can solve the whole problem.

setup is just to set up hardware and initial states.

Your "main program" is actually loop().

One solution is to think of loop as your main program. If you exit loop, yes, you will come back in. But, there is nothing to stop you from putting your own loops inside loop().

So:

void loop()
{
    do some initial things here

    // this is your loop
    for ()
    {
    }

    do the final things here

    // and finally, loop forever here so we don't exit and come back into the loop.
    // to start again, we would have to press the Arduino RESET button
    for (1) {}
}

Alternatively, you could use a simple state machine, or millis() test inside your loop.

For example

const int RUNNING = 0;
etc.

int state = RUNNING;
void  loop()
{
    if (state == RUNNING)
    {
       do stuff here
       if (some condition)
       {
          state = FINISHING;
       }
    }
    else if (state == FINISHING)
    {
       do final stuff;
       state = FINISHED;
    }
}

You might also get some useful ideas in Planning and Implementing a Program

Think of your program structure like this

void setup() {

}
void loop() {
   if (jobNotFinished) {
       doMoreWork();
   }
   else {
      tidyUp();
   }
}

...R