static int step = 4;
static int dir = 3;
static int button = 5;
static int button2 = 6;
void setup() {
  int zasuk = 10;
 Serial.begin(9600);
 pinMode(step, OUTPUT);
 pinMode(dir, OUTPUT);
 pinMode(button, INPUT);
 pinMode(button2, INPUT);

}

void loop() {
  if (digitalRead(button) == 1){
    digitalWrite(dir, HIGH);
  for (int i = 0; i < zasuk; i++){
    korak();
    delay(10);
  }


delay(500);

  }
  if (digitalRead(button2) == 1){
  
  digitalWrite(dir, LOW);
  for (int i = 0; i < zasuk; i++){
    korak();
    delay(10);
  }



delay(500);

}
}

void korak(){
    

digitalWrite(step, HIGH);
delayMicroseconds(10);
digitalWrite(step, LOW);
delayMicroseconds(10);
}
A4988