stepper motor project

i have been making an stepper motor that goes one way when you press button one and the other way when you press button two.

this is my code:

int motorPin1 = 8;
int motorPin2 = 9;
int motorPin3 = 10;
int motorPin4 = 11;
int delayTime = 3;
const int LEFT = 3;
const int RIGHT = 4;
int var = 0;

void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
pinMode(LEFT, INPUT);
pinMode(RIGHT, INPUT);
}

void loop() {

if(digitalRead(LEFT) == HIGH)
{

(var=1);
}

if(digitalRead(RIGHT) == HIGH)

{
(var=2);
}
switch(var) {
case 1:
digitalWrite(motorPin4, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay(delayTime);
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay(delayTime);
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin1, LOW);
delay(delayTime);
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, HIGH);
delay(delayTime);
break;
case 2:
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, HIGH);
delay(delayTime);
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin1, LOW);
delay(delayTime);
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay(delayTime);
digitalWrite(motorPin4, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay(delayTime);
break;
default:
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay(delayTime);
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay(delayTime);
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay(delayTime);
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay(delayTime);
break;
}
}

everytime is start it up the stepper motor is running one way roughly when i do nothing. when i press the button it runs smoothly. and when i press theother button it tries to go the other way but it can't

can anyone help me

How are the inputs wired ?

Do you have any pullup or pulldown resistors in place or are the inputs floating at an unknown voltage when the buttons are not pressed ?

The code looks OK so I expect a hardware error. Like UKHeliBob, I think one or both of your inputs is floating when the button is not pressed.

You need a pull-up resistor (INPUT_PULLUP or external) when the button is between the pin and Ground. HIGH means NOT pressed and LOW means pressed.

You need an external pull-down resistor when the button is between the pin and +5V. HIGH means pressed and LOW means NOT pressed.