Programmable tank

I got the arduino rover kit (just the chassis, treads, and motor) and I hooked up an h bridge. It works fine.

I'm trying to make a robot where you can program a series of four actions (left, forward, right) by pushing buttons.

Something is going wrong with the button pressing.
Here's the code:

int en1 = 5;
int en2 = 9;
int s1log1 = 3;
int s1log2 = 4;
int s2log1 = 7;
int s2log2 = 8;
int button1 = 10;
int button2 = 11;
int button3 = 12;
int light = 2;
int pot = 0;

int act1 = 0;
int act2 = 0;
int act3 = 0;
int act4 = 0;

int calib = 1000;
int time1 = 0;
int time2 = 0;
int time3 = 0;
int time4 = 0;
boolean do180 = false;

void setup()  {
  pinMode(en1, OUTPUT);
  pinMode(en2, OUTPUT);
  pinMode(s1log1, OUTPUT);
  pinMode(s1log2, OUTPUT);
  pinMode(s2log1, OUTPUT);
  pinMode(s2log2, OUTPUT);
  pinMode(light, OUTPUT);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  pinMode(button3, INPUT);
  digitalWrite(button1, HIGH);
  digitalWrite(button2, HIGH);
  digitalWrite(button3, HIGH);
  //==============================================
  digitalWrite(light, HIGH);
  while((digitalRead(button1) == LOW && digitalRead(button2) == LOW) && digitalRead(button3) == LOW)  {
  }
  delay(10);
  if(digitalRead(button1) == HIGH)  {
    act1 = 1;
  }
  else if(digitalRead(button2) == HIGH)  {
    act1 = 2;
  }
  else if(digitalRead(button3) == HIGH)  {
    act1 = 3;
  }
  int num = analogRead(pot);
  time1 = map(num, 0, 1023, 100, 1000);
  //================================================
  digitalWrite(light, LOW);
  delay(1000);
  while((digitalRead(button1) == LOW && digitalRead(button2) == LOW) && digitalRead(button3) == LOW)  {
  }
  delay(10);
  if(digitalRead(button1) == HIGH)  {
    act2 = 1;
  }
  else if(digitalRead(button2) == HIGH)  {
    act2 = 2;
  }
  else if(digitalRead(button3) == HIGH)  {
    act2 = 3;
  }
  num = analogRead(pot);
  time2 = map(num, 0, 1023, 100, 1000);
  digitalWrite(light, LOW);
  delay(1000);
  //================================================
  digitalWrite(light, LOW);
  delay(1000);
  while((digitalRead(button1) == LOW && digitalRead(button2) == LOW) && digitalRead(button3) == LOW)  {
  }
  delay(10);
  if(digitalRead(button1) == HIGH)  {
    act3 = 1;
  }
  else if(digitalRead(button2) == HIGH)  {
    act3 = 2;
  }
  else if(digitalRead(button3) == HIGH)  {
    act3 = 3;
  }
  num = analogRead(pot);
  time3 = map(num, 0, 1023, 100, 1000);
  digitalWrite(light, LOW);
  delay(1000);
  //================================================
  digitalWrite(light, LOW);
  delay(1000);
  while((digitalRead(button1) == LOW && digitalRead(button2) == LOW) && digitalRead(button3) == LOW)  {
  }
  delay(10);
  if(digitalRead(button1) == HIGH)  {
    act4 = 1;
  }
  else if(digitalRead(button2) == HIGH)  {
    act4 = 2;
  }
  else if(digitalRead(button3) == HIGH)  {
    act4 = 3;
  }
  num = analogRead(pot);
  time2 = map(num, 0, 1023, 100, 1000);
  digitalWrite(light, LOW);
  delay(1000);
  //===================================================
  digitalWrite(light, HIGH);
  delay(250);
  digitalWrite(light, LOW);
  delay(250);
  digitalWrite(light, HIGH);
  delay(250);
  digitalWrite(light, LOW);
  delay(250);
  digitalWrite(light, HIGH);
  delay(250);
  digitalWrite(light, LOW);
  delay(250);
  digitalWrite(light, HIGH);
  while(digitalRead(button1) == LOW && digitalRead(button2) == LOW)  {
  }
  delay(10);
  if(digitalRead(button1) == HIGH)  {
    do180 = true;
  }
  else if(digitalRead(button2) == HIGH)  {
    do180 = false;
  }
  digitalWrite(light, LOW);
  delay(1000);
}

void loop()  {
  switch (act1)  {
    case 1:
    turnleft(time1);
    break;
    case 2:
    gofwd(time1);
    break;
    case 3:
    turnright(time1);
    break;
  }
  switch (act2)  {
    case 1:
    turnleft(time2);
    break;
    case 2:
    gofwd(time2);
    break;
    case 3:
    turnright(time2);
    break;
  }
  switch (act3)  {
    case 1:
    turnleft(time3);
    break;
    case 2:
    gofwd(time3);
    break;
    case 3:
    turnright(time3);
    break;
  }
  switch (act4)  {
    case 1:
    turnleft(time4);
    break;
    case 2:
    gofwd(time4);
    break;
    case 3:
    turnright(time4);
    break;
  }
  if(do180 == true)  {
    turn180();
  }
}

void gofwd(int time)  {
  digitalWrite(s1log2, LOW);
  digitalWrite(s1log1,HIGH);
  digitalWrite(s2log2, LOW);
  digitalWrite(s2log1,HIGH);
  digitalWrite(en1, HIGH);
  digitalWrite(en2, HIGH);
  delay(time);
  stop();
}

void stop()  {
  digitalWrite(en1, LOW);
  digitalWrite(en2, LOW);
}

void turnleft(int time)  {
  digitalWrite(s1log1, LOW);
  digitalWrite(s1log2,HIGH);
  digitalWrite(s2log2, LOW);
  digitalWrite(s2log1,HIGH);
  digitalWrite(en1, HIGH);
  digitalWrite(en2, HIGH);
  delay(time);
  stop();
}

void turnright(int time)  {
  digitalWrite(s1log2, LOW);
  digitalWrite(s1log1,HIGH);
  digitalWrite(s2log1, LOW);
  digitalWrite(s2log2,HIGH);
  digitalWrite(en1, HIGH);
  digitalWrite(en2, HIGH);
  delay(time);
  stop();
}

void turn180()  {
  digitalWrite(s1log1, LOW);
  digitalWrite(s1log2,HIGH);
  digitalWrite(s2log2, LOW);
  digitalWrite(s2log1,HIGH);
  digitalWrite(en1, HIGH);
  digitalWrite(en2, HIGH);
  delay(calib);
}

You're only reading the buttons in "setup" which only gets called once.
Is that what you expect to do?

Something is going wrong with the button pressing

Isn't very helpful.

Sorry. What I want is to, at the beginning of the program, you pick a series of actions. Then it repeats that sequence over and over.

Nevermind!!! It works perfectly now that I fixed it!
BTW, one of the problems was that in the while loops and the if structures in setup(), the HIGH and LOW states were the opposite of what they should be.

This is what it does:
It turns on a light, and then you set the potentiometer to hoe long you want it to do the action, and press the corresponding action button. It repeats this five times.
Then, it does your sequence of actions (left, right, or forward) for 0.1 - 1 second each, according to what you set the potentiometer to.
Then it repeats the sequence again and again!

One thing I might add in the future is a way to set how many actions in the sequence. Any idea how to do this?

Here is the code so far:

int en1 = 5;
int en2 = 9;
int s1log1 = 3;
int s1log2 = 4;
int s2log1 = 7;
int s2log2 = 8;
int button1 = 10;
int button2 = 11;
int button3 = 12;
int light = 2;
int pot = 0;

int act1 = 0;
int act2 = 0;
int act3 = 0;
int act4 = 0;
int act5 = 0;

int calib = 1000;
int time1 = 0;
int time2 = 0;
int time3 = 0;
int time4 = 0;
int time5 = 0;
boolean do180 = false;

void setup()  {
  pinMode(en1, OUTPUT);
  pinMode(en2, OUTPUT);
  pinMode(s1log1, OUTPUT);
  pinMode(s1log2, OUTPUT);
  pinMode(s2log1, OUTPUT);
  pinMode(s2log2, OUTPUT);
  pinMode(light, OUTPUT);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  pinMode(button3, INPUT);
  digitalWrite(button1, HIGH);
  digitalWrite(button2, HIGH);
  digitalWrite(button3, HIGH);
  //==============================================
  digitalWrite(light, HIGH);
  while((digitalRead(button1) == HIGH && digitalRead(button2) == HIGH) && digitalRead(button3) == HIGH)  {
  }
  delay(10);
  if(digitalRead(button1) == LOW)  {
    act1 = 1;
  }
  else if(digitalRead(button2) == LOW)  {
    act1 = 2;
  }
  else if(digitalRead(button3) == LOW)  {
    act1 = 3;
  }
  int num = analogRead(pot);
  time1 = map(num, 0, 1023, 100, 1000);
  digitalWrite(light, LOW);
  delay(1000);
  //================================================
  digitalWrite(light, HIGH);
  delay(1000);
  while((digitalRead(button1) == HIGH && digitalRead(button2) == HIGH) && digitalRead(button3) == HIGH)  {
  }
  delay(10);
  if(digitalRead(button1) == LOW)  {
    act2 = 1;
  }
  else if(digitalRead(button2) == LOW)  {
    act2 = 2;
  }
  else if(digitalRead(button3) == LOW)  {
    act2 = 3;
  }
  num = analogRead(pot);
  time2 = map(num, 0, 1023, 100, 1000);
  digitalWrite(light, LOW);
  delay(1000);
  //================================================
  digitalWrite(light, HIGH);
  delay(1000);
  while((digitalRead(button1) == HIGH && digitalRead(button2) == HIGH) && digitalRead(button3) == HIGH)  {
  }
  delay(10);
  if(digitalRead(button1) == LOW)  {
    act3 = 1;
  }
  else if(digitalRead(button2) == LOW)  {
    act3 = 2;
  }
  else if(digitalRead(button3) == LOW)  {
    act3 = 3;
  }
  num = analogRead(pot);
  time3 = map(num, 0, 1023, 100, 1000);
  digitalWrite(light, LOW);
  delay(1000);
  //================================================
  digitalWrite(light, HIGH);
  delay(1000);
  while((digitalRead(button1) == HIGH && digitalRead(button2) == HIGH) && digitalRead(button3) == HIGH)  {
  }
  delay(10);
  if(digitalRead(button1) == LOW)  {
    act4 = 1;
  }
  else if(digitalRead(button2) == LOW)  {
    act4 = 2;
  }
  else if(digitalRead(button3) == LOW)  {
    act4 = 3;
  }
  num = analogRead(pot);
  time4 = map(num, 0, 1023, 100, 1000);
  digitalWrite(light, LOW);
  delay(1000);
  //===================================================
  digitalWrite(light, HIGH);
  delay(1000);
  while((digitalRead(button1) == HIGH && digitalRead(button2) == HIGH) && digitalRead(button3) == HIGH)  {
  }
  delay(10);
  if(digitalRead(button1) == LOW)  {
    act5 = 1;
  }
  else if(digitalRead(button2) == LOW)  {
    act5 = 2;
  }
  else if(digitalRead(button3) == LOW)  {
    act5 = 3;
  }
  num = analogRead(pot);
  time5 = map(num, 0, 1023, 100, 1000);
  digitalWrite(light, LOW);
  delay(1000);
}

void loop()  {
  switch (act1)  {
  case 1:
    turnleft(time1);
    break;
  case 2:
    gofwd(time1);
    break;
  case 3:
    turnright(time1);
    break;
  }
  switch (act2)  {
  case 1:
    turnleft(time2);
    break;
  case 2:
    gofwd(time2);
    break;
  case 3:
    turnright(time2);
    break;
  }
  switch (act3)  {
  case 1:
    turnleft(time3);
    break;
  case 2:
    gofwd(time3);
    break;
  case 3:
    turnright(time3);
    break;
  }
  switch (act4)  {
  case 1:
    turnleft(time4);
    break;
  case 2:
    gofwd(time4);
    break;
  case 3:
    turnright(time4);
    break;
  }
  switch (act5)  {
  case 1:
    turnleft(time5);
    break;
  case 2:
    gofwd(time5);
    break;
  case 3:
    turnright(time5);
    break;
  }
}

void gofwd(int time)  {
  digitalWrite(s1log2, LOW);
  digitalWrite(s1log1,HIGH);
  digitalWrite(s2log2, LOW);
  digitalWrite(s2log1,HIGH);
  digitalWrite(en1, HIGH);
  digitalWrite(en2, HIGH);
  delay(time);
  stop();
}

void stop()  {
  digitalWrite(en1, LOW);
  digitalWrite(en2, LOW);
}

void turnleft(int time)  {
  digitalWrite(s1log2, LOW);
  digitalWrite(s1log1,HIGH);
  digitalWrite(s2log1, LOW);
  digitalWrite(s2log2,HIGH);
  digitalWrite(en1, HIGH);
  digitalWrite(en2, HIGH);
  delay(time);
  stop();
}

void turnright(int time)  {
  digitalWrite(s1log1, LOW);
  digitalWrite(s1log2,HIGH);
  digitalWrite(s2log2, LOW);
  digitalWrite(s2log1,HIGH);
  digitalWrite(en1, HIGH);
  digitalWrite(en2, HIGH);
  delay(time);
  stop();
}