simple open/close action with servo?

I am working with an Arduino Uno a 16 channel pwm servo driver, and some basic servos. I am trying to get the servos to "open" (move to 180 degrees) based on a sensor input, then "close" (move back to 0 degrees) when sensor is not reading said input. How can I keep the servo at 180 degrees without automatically returning to zero? The code im working with is below.

      if (sensorValue < 75  ) {
  for (uint16_t angle = 0; angle < 180; angle++) {
    pwm.setPWM(1, 0, map(angle, 0, 180, SERVOMIN, SERVOMAX));
    delay(20);
  }
      }
  
  if (sensorValue > 75  ) {
  for (uint16_t angle = 180; angle > 0; angle--) {
    pwm.setPWM(1, 0, map(angle, 0, 180, SERVOMIN, SERVOMAX));
    delay(30);
  } 
    }
}

Do away with the for loop and just use pwm.setPWM(1, 0, 180) to move the servo to 180 degrees and it will stay there. If you want the servo to move slowly then you need to set a flag to indicate that it has moved to 180 degrees and use an if statement to test the flag value, and only do the for loop if it is not already at 180 degrees.

if sensor value less than 75 and servo180 not equal to 1
  for loop to move servo to 180 slowly
  servo180 = 1
end of if