const int stepsPerRevolution = 200;
const int in1Pin = 22;
const int in2Pin = 23;
const int in3Pin = 24;
const int in4Pin = 25;
int stepCount = 0;
float degreesPerStep = 360.0 / stepsPerRevolution;

void setup() {
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);
  Serial.begin(9600);
}

void stepMotor(int in1, int in2, int in3, int in4) {
  digitalWrite(in1Pin, in1);
  digitalWrite(in2Pin, in2);
  digitalWrite(in3Pin, in3);
  digitalWrite(in4Pin, in4);
  delay(10);
}

void stepForward() {
  stepMotor(HIGH, LOW, LOW, LOW);
  stepMotor(LOW, HIGH, LOW, LOW);
  stepMotor(LOW, LOW, HIGH, LOW);
  stepMotor(LOW, LOW, LOW, HIGH);
}

void stepBackward() {
  stepMotor(LOW, LOW, LOW, HIGH);
  stepMotor(LOW, LOW, HIGH, LOW);
  stepMotor(LOW, HIGH, LOW, LOW);
  stepMotor(HIGH, LOW, LOW, LOW);
}

void loop() {
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < stepsPerRevolution / 15; j++) { // 90 derajat
      stepForward();
      stepCount++;
      if (stepCount >= stepsPerRevolution / 15) {
        delay(500);
        stepCount = 0;
      }
    }
  }

  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < stepsPerRevolution / 8; j++) { // 180 derajat
      stepBackward();
      stepCount++;
      if (stepCount >= stepsPerRevolution / 8) {
        delay(500);
        stepCount = 0;
      }
    }
  }
}