start code from the begining .How?

acmiilangr:
I have a program that makes some tasks and it checks for infrared signals.

all i want is every time it checks for IR signals i want the scetch to start from begining. I tried with goto but it only works inside their void

Since you want the 3 tasks to do something different, (and presumably if you notice IR data after task_1 you want to skip task_2), you might want something like this: (using flags)

byte incoming_IR_data;
boolean IR_received;  // Flag for knowing if you have to do something different when IR information has been received. Should initialize to 0 (which ==FALSE)

void setup() {                

  pinMode(13, OUTPUT);     
}

void loop() {
  if (IR_received)  // 
  {
    // code to handle IR stuff if needed. Otherwise unwrap the following line out of the if statement.
    IR_received = FALSE;  // (Re)set the received flag
  }
  task_0(); 
  task_1();
  task_2();  
}

void task_0()
{
  // don't need to check IR_received here because we haven't checked IR communication since we last reset the flag
  //some code here
   check_IR();
}
void task_1()
{

  if (!IR_received)  // if IR_received == FALSE
  {
    return; // return from the function w/o doing anything
  }
  
  //some code here
   check_IR();
}
void task_2()
{

  if (!IR_received)  // if IR_received == FALSE
  {
    return; // return from the function w/o doing anything
  }
  
  //some code here
   check_IR();
}
void check_IR()
{
 //Some code that checks IR and stores data from Infrared to incoming_IR_data variable
 
     if (incoming_IR_data==12524)
     {
       IR_received == TRUE;  // Set the flag that basically neuters the other functions.
     }
}

Now, I'm not sure if this is what you really want, but I think it should do what you asked. :wink: