Calculate the correct current limit for driver A4988

this works decent now. However I had to lower the speed a lot to make it run at 6 volt. But it is not very smooth going CCW. Since it is goes a bit jaggy it struggles to keep its position as well. I was expecting the stepper to go 200 steps CW and then go 200 CCW but it is going out of position.

I dont know if there are any further improvements to be made to make it run smooth otherwise I think I might need to look for another option. Any opinions?

(I guess I am a bit out of topic now so I might start a new thread ... )

Here is my code again:

const int coilA = 2;
const int coilB =  3;
const int ms = 2500;

int inc = 0;
bool changeDir = false;

void setup() {
  Serial.begin(9600);

  pinMode(coilA, OUTPUT);
  pinMode(coilB, OUTPUT);
  digitalWrite(coilA, LOW);
  digitalWrite(coilB, LOW);
}

void loop() {
  if (inc % 200 == 0) {
    changeDir = !changeDir;
    if (changeDir == 1) {
      Serial.println("CW");
    } else if (changeDir == 0) {
      Serial.println("CCW");
    }
    delay(10);
  }
  if (changeDir == 1) {
    cw();
  } else if (changeDir == 0) {
    ccw();
  }
  inc++;
}

void cw() {
  step1();
  step2();
  step3();
  step4();
}

void ccw() {
  step4();
  step3();
  step2();
  step1();
}

void step1 () {
  digitalWrite(coilA, LOW);
  digitalWrite(coilB, HIGH);
  delayMicroseconds(ms);
}

void step2 () {
  digitalWrite(coilA, HIGH);
  digitalWrite(coilB, HIGH);
  delayMicroseconds(ms);
}

void step3 () {
  digitalWrite(coilA, HIGH);
  digitalWrite(coilB, LOW);
  delayMicroseconds(ms);
}

void step4 () {
  digitalWrite(coilA, LOW);
  digitalWrite(coilB, LOW);
  delayMicroseconds(ms);
}