does such code exist??

hello guys!
i am wondering if this is possible
any help is greatly appreciated :slight_smile:

normally the code goes through loop until it pauses and executes code X

for example

void loop(

doing code A

pause

execute code X //when it finishes, it returns to where it stopped and continue

unpause

continue code A

pause

execute code X //when it finishes, it returns to where it stopped and continue

unpause

continue code A

pause

..........................keep repeating....

is this possible?? the "X" code would be separately located in the code

the important this is after executing the code "X" it has to return to the

exact point where code "A" stopped

any help is greatly appreciated!!

It is called a "function".

loop()
{
      runA();
      executeX();
}

void runA()
{
//do a bunch of stuff
}

void executeX()
{
//do some other stuff
}

http://playground.arduino.cc/Code/Function

luv you guys! thanks a million!! :slight_smile:

Since you're talking about "pausing" Code A, it sounds more like you need Code X to be contained in an interrupt.

What would be triggering Code X to run? That would determine the interrupt you use (timer, external, etc.).

You may find some useful stuff in Planning and Implementing a Program

It illustrates the use of functions and the use of millis() to manage timing without blocking.

...R

I doubt he want's to use an interrupt. Just don't execute it if you want to "pause" it.

loop(){
  if(doIneedToExecuteA){
    runA();
  }
  executeX();
}

void runA(){
  //do a bunch of stuff
}

void executeX(){
  //do some other stuff
}