jung6717 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

'if else' lock ups #219

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This code consistently locks up:
-----------------------------------------------
if ((sensorValue>threshold) && (setFlag==0)) {
       k++;
       setFlag=1;
     }  
     else if (sensorValue<=threshold) {
       setFlag=0;
     }
     else {
       continue;
}
-----------------------------------------------
this code works fine:
-----------------------------------------------
if ((sensorValue>threshold) && (setFlag==0)) {
       k++;
       setFlag=1;
}  
if (sensorValue<=threshold) setFlag=0;
-----------------------------------------------

Original issue reported on code.google.com by itstheme...@gmail.com on 10 Mar 2010 at 8:15

GoogleCodeExporter commented 8 years ago
I suspect that continue statement is reaching up to the while loop that 
represents
the entire event loop.

Is this code in your own do, for or while loop? Because if it is not, I bet it 
is
just reaching the while(true) event loop.

Original comment by clvrm...@gmail.com on 10 Mar 2010 at 9:18

GoogleCodeExporter commented 8 years ago
Yes it is in my own loop.

Original comment by itstheme...@gmail.com on 10 Mar 2010 at 11:05

GoogleCodeExporter commented 8 years ago
This looks like a problem with the particular code, not a bug in the Arduino 
software.

Original comment by dmel...@gmail.com on 16 Dec 2011 at 10:09