// lr_servo.detach(); //release the pin of servo
lr_servo.write(lr_angle); //output the angle of servo
}
/***************system adjusting up and down**********************/
if (abs(U - D) > error && U >= D) { //Determine whether the error is
within the acceptable range, otherwise adjust the steering gear
ud_angle -= resolution;//reduce the angle
// ud_servo.attach(ud_servopin); // connect servo
if (ud_angle < 10) { //limit the rotation angle of servo
ud_angle = 10;
}
ud_servo.write(ud_angle); //output the angle of servo
delay(m_speed);
}
else if (abs(U - D) > error && U < D) { //Determine whether the error
is within the acceptable range, otherwise adjust the steering gear
ud_angle += resolution;//increase the angle
// ud_servo.attach(ud_servopin); // connect servo
if (ud_angle > 90) { //limit the rotation angle of servo
ud_angle = 90;
}