help with servo project !

you have no check for a buttonpress in your whole code, that's why it just keeps on going. just add a statement for a buttonpress in the main loop and it should work.

void loop() {
   if (digitalRead(pin) == HIGH) { 
      //whole loop code
   }
}

this should work