Hey everyone! I am making a sensor-based guide system and it seems like my program over lapse each other or the operations in my if/else statement are not doing what I want it to do.
I wonder if I can use AND "&&" with OR "||" like:
distance1>5 && (distance2<=5 || distance3<=5).
Does the operation inside the "()" acts like one operation or it is just the same as:
distance1>5 && distance2<=5 || distance3<=5 ?
I wanted it to work with my first statement, but it seems like I'm not able to do so.
I need help.
this is my code:
if (distance5<570 && distance5>420){
Serial.println("UP STAIR");
}
else if(distance5>570 && distance5<710){
Serial.println("DOWN STAIR");
}
else if(distance5<420 || distance5>710){
Serial.println("TURN RIGHT");
else if(distance1>500 && ( distance2<=500|| distance3<=500 || distance4<=500 )){
Serial.println("TURN RIGHT");
}
else if(distance1<=500){
Serial.println("TURN LEFT");
}
else if((distance1 <=500 && distance2<=500)&&(distance3<=500 || distance4<=500)){
Serial.println("ROTATE");
}
else{
Serial.println("")
}