Pause

Hi, I try to suspend the program, I have no problem to suspend it, if I press button, Pause function start with no problem, but I have problem run it again. If I press button again, it do nothing. Thank you for help and sorry for my english.

Code:

void FunctionItrySuspend()
{
   attachInterrupt(4,Pause,RISING);
    ...
    ...
   lots of code
}

void Pause()
{
        detachInterrupt(4);
	delay(500);
	attachInterrupt(4,FunctionItrySuspend,RISING);
	
	lcd.clear();

	while (1)
	{
               lcd.setCursor(0,0);
	       lcd.print("PAUSE");
	}
}
delay(500);

nside the attached function, delay() won't work and the value returned by millis() will not increment.

Tank you for reply. But it's not nature of my problem, no? If you can not delay, it would only cause that sometimes the program pauses and sometimes not, depending on whether the button was pressed by the even number or an odd number. Or am I wrong?

void Pause()
{
        detachInterrupt(4);  // take the rising edge interrupt off the pin
	delay(500);  // never do anything, ever
	attachInterrupt(4,FunctionItrySuspend,RISING); //never reach here
	
	lcd.clear();

Oh, I do understand it now. Thank you.

Why do you think? I needed to function executed until you press button again.

Don't use an interrupt. Use a state machine.