Running a function with 10second duration out of loop function

Hello,

I want to create a function which I call out of the void loop().
In this function I want to enable a digital output for 10 seconds.
But when the do is enabled, the void loop() function has to continue during the 10 seconds.

Is it possible, and how?
Best regards

Hello,

See the Blink Without Delay example

The demo several things at a time is an extended example of the BWoD technique

Basically, you switch on and save the value of millis() and then keep checking the value of millis() in loop() and when 10 secs have elapsed it is time to switch off.

...R

Thanks for the links.

I got the following pseudo-code:

boolean AlarmStatus = FALSE;

void loop()
{
int i = 5;

if (i==5)
    {
    // switch to a alarm function
    alarm();

    }

}

void alarm()
{
if (AlarmStatus==TRUE)
    {
     // Turn on a digital output for 10 seconds
     }
}

So which elements of BlinkWithNoDelay and Several things at a time do I really need for my minimalistic code?

//Edit:

I want that the LED in void alarm() is just running 10 seconds. After 10 seconds the LED has to get off by itself, without starting the function again.

boolean AlarmStatus = FALSE;

boolean showing_alarm=false ;
unsigned long alarm_start_time;

void loop()
{

if ( showing_alarm && (millis()-alarm_start_time >= 10000 ))
{
     digitalWrite( alarm_Pin, LOW );
     showing_alarm = false ;
}


int i = 5;

if (i==5)
    {
    if ( alarmCondition && !showing_alarm )
    {
         digitalWrite( alarm_Pin,  HIGH );
         showing_alarm = true ;
         alarm_start_time = millis();
    }

    }

}