Range in distance

i need help with this code. i have two motors in my project that i want to be set at a default angle of 0 degrees.

if (distance > 200) {
myservo1.write(70); // set servo to mid point
myservo2.write(0); // set servo to mid point
digitalWrite(LEDPinV, HIGH);
digitalWrite(LEDPinVI, LOW);
digitalWrite(Buzzer, HIGH);
}
else if (distance <= 200){
myservo1.write(0);
myservo2.write(70);
digitalWrite(LEDPinV, LOW);
digitalWrite(LEDPinVI, HIGH);
}
else {
myservo1.write(1);
myservo2.write(1);
digitalWrite(LEDPinV, LOW);
digitalWrite(LEDPinVI, LOW);
}
}

this is what i have so far but the problem is i need to set the distance as a range and not more than or less that 200. is there any way i can set it as distance = 10-200 or something like this ?

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

if (distance >= 10 && distance <= 200)
{
  //do this
}

thank you and i will make sure to use the code tags next time

Why wait? Use the edit post icon you have after your post and change it now.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.