> Need help in the programming ?

Need help in the programming ?

Posted at: 2014-12-18 
bool CallAgain = 0;

loop() % infinite loop

{

if (CallAgain){

CallAgain = 0;

CallFunctionToDoStuff();

}

if (IsSense)

{

CallAgain = 1;

CallFunctionToDoStuff();

}

}

I have a function which dependence on sensor reading located inside infinite loop , if the sensor senses any value , the function should call , after that it should follow with another call to same function in next time (next loop) even when sensor didn't sense .

I write an example below to show that , for any loop iteration if IsSense reads or senses any value, the CallFunctionToDoStuff() is called normally and at here no problem but , in the next loop I want the program to call the same function even when IsSense didn't sense any thing and so on , in another meaning each call to the function CallFunctionToDoStuff() after a verification condition , should follow with another call to same CallFunctionToDoStuff() in next loop even if IsSense didn't sense any thing .

so in one word , there are two conditions to call the function CallFunctionToDoStuff();

1- If currently , the sensor (IsSense) sense any value .

2- If Previously (in the previous loop ) , the sensor (IsSense) sense any value .

loop() % infinite loop

{

if (IsSense)

{

CallFunctionToDoStuff();

}

}

I think the first condition is OK to me , but second condition is not , how to make the program know that the function is called in the previous loop ?