programmed button

help, I have a ready source and I need not repeat just once
and I would like to be able to start by pressing the button and returns to the starting position. I do not know how programmed button

#include <Servo.h>

Servo vertical_servo; //

int servo_pos = 0; //
//

int i = 0; //
//

void setup()
{
vertical_servo.attach(9); //
//
}

void loop()
{

for(i = 0; i <= 1; i += 1) //
//
{
vertical_servo.write(40); //
delay(2000);
//
vertical_servo.write(-23); //
delay(2000);
vertical_servo.write(50); //
delay(2000);
vertical_servo.write(70); //
delay(2000);
vertical_servo.write(90); //
delay(2000); //
vertical_servo.write(180); //
delay(2000);
vertical_servo.write(0); //
delay(220); //
}
}

muterce:
help, I have a ready source and I need not repeat just once
and I would like to be able to start by pressing the button and returns to the starting position. I do not know how programmed button

I don't understand this - please explain more clearly what you want to do.

Please edit your post and use the code button '</>' so your code

looks like this

I suggest you don't use the delay() function. see how millis() is used to manage timing in several things at a time. It may also give you some ideas about how to solve your problem.

...R

I don't think you are ready for millis() and it is not needed for your current code so use delay().

This should help you with how to read a button: