Servo Motor Programming Help

Hello, I am making a swinging paper airsoft target using 1 Servo motor and an Arduino Uno R3. What I want the target to do is on the push of a button start looping a line of code which swings the target out at a random time, then it stays out in a shootable position for a set time, then recedes back and loops around again. I want to use 2 buttons on my breadboard, the left button will activate the code and the code will continue to loop until the right button is pushed which I want to bring the target to a static position and hold it until the first button is pushed again. Any tips on how to program this would be appreciated.

The tricky part is responding to the buttons. If you didn't have to do that then it would be simple...

#define hiddenPosition 10 //degrees of servo movement
#define shootingPosition 160 //degrees
#define hiddenTime 2000 //milliseconds to stay in hidden position
#define shootingTime 2000 //milliseconds to stay extended

void setup() {
  //attach servo etc.

void loop() {

To make it respond to buttons, you will have to first convert this to use millis() instead of delay(). See the tutorial in the sticky topic at the top. Then add the buttons.