Thank you for taking the time to look at my question and give some examples, much appreciated.
I may have given a too basic example of my if statement.
This is one of the smaller if statements I am currently using.
if ( (micros() - start_t >= timeout_t) || (trip_count >= trip_threshold) || (low_count, >= low_threshold) || (high_count >= high_threshold) ){
}
// Debug - Print out all variables to check what passed the if statement.
Serial.printf("Adc: %d, %d uSec, Low: %d, High: %d, Loop: %d, Trip: %d \n", adc_val, end_t, low_count, high_count, loop_count +1, trip_count);
// Do other things......
}
I did consider doing something like @alto777 suggested but was worried it was wasting clock cycles? and am sure it could be done more elegantly.
int pass_code = 0;
if (micros() - start_t >= timeout_t) {
pass_code = 1;
}else if (trip_count >= trip_threshold) {
pass_code = 2;
} else if (low_count >= low_threshold) {
pass_code = 3;
} else if (high_count >= high_threshold) {
pass_code = 4;
}
if (pass_code >> 0){
// Debug - Print out pass_code
Serial.println(pass_code);
// Do other things......
}
So if I understand what your both saying correctly, using else if will still check the other conditions even if the first one is true?