Reading the position of a flex sensor to set a limit

Another approach is to use some sort of mode condition.

loop() {
  if we are in limit setting mode
    do the limit setting loop
  else
    do the normal operation loop
}

limit_setting_loop() {
  if the "end of mode" button is pressed (released, whatever)
    set mode to normal operation
  else
    if the 'set upper limit' switch is pressed
      record the upper limit

  etc etc
}

normal_operation_loop() {
  if the "set limits mode" button is pressed (released, whatever)
    set mode to setting limits
  else
    do the normal stuff
}