Agregar conteo

Hola muy buenos días, tengo el siguiente código de programación, es un motor paso a paso con el cual se hace un movimiento en sentido horario y uno en anti horario, estuve intentando agregar un contador para que cuando haga un movimiento en ambos sentidos haya un contador que me vaya diciendo cuantas veces lo hace. Realmente lo intente y no pude, alguien me podría ayudar??

CODIGO:

//definicion de pins
const int motorPin1 = 8; // 28BYJ48 In1
const int motorPin2 = 9; // 28BYJ48 In2
const int motorPin3 = 10; // 28BYJ48 In3
const int motorPin4 = 11; // 28BYJ48 In4

//definicion variables
int motorSpeedoff = 0;
int motorSpeedsentidohorario = 0; //variable para fijar la velocidad (cuanto disminuyo mas rapido es)
int motorSpeedsentidoantihorario = 0;
int stepCounter = 0; // contador para los pasos
int stepsPerRev = 0; // pasos para una vuelta completa (modificar aca para poder variar la carrera)

//secuencia media fase
const int numSteps = 8;
const int stepsLookup[8] = { B1000, B1100, B0100, B0110, B0010, B0011, B0001, B1001 };

bool comandoIngresado=false;
String inputString = ""; // a String to hold incoming data
bool stringComplete = false; // whether the string is complete

void setup()
{
//declarar pines como salida
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
Serial.begin(9600); // Abrir el puerto serie a la velocidad de 9600bps para trasnmicion de datos.
Serial.println("Introducir: Desplazamiento, Velocidad sentido horario, Velocidad sentido antihorario: ");
}

void loop()
{
if (stringComplete) { //chequea si el flag stringComplete esta en true--> la cadena esta completa
Serial.println(inputString); //la imprime por el puerto serie
// desarmar el string pasando los valores a las variables que usas en el for
String steps=inputString.substring(0,4);

stepsPerRev=steps.toInt();
steps=inputString.substring(5,9);
motorSpeedsentidohorario=steps.toInt();
steps=inputString.substring(10,14);
motorSpeedsentidoantihorario=steps.toInt();
Serial.print("Desplazamiento: ");
Serial.println(stepsPerRev);
Serial.print("Velocidad Horaria: ");
Serial.println(motorSpeedsentidohorario);
Serial.print("Velocidad Anti Horaria: ");
Serial.println(motorSpeedsentidoantihorario);

inputString = ""; //la vacia
stringComplete = false; // resetea el flag
comandoIngresado=true;
}

if (comandoIngresado){
for (int i = 0; i < stepsPerRev * 2; i++)
{
clockwise();
delayMicroseconds(motorSpeedsentidohorario);
}
for (int i = 0; i < stepsPerRev * 2; i++)
{
anticlockwise();
delayMicroseconds(motorSpeedsentidoantihorario);
}
delay(0);
}
}

void clockwise()
{
stepCounter++;
if (stepCounter >= numSteps) stepCounter = 0;
setOutput(stepCounter);
}

void anticlockwise()
{
stepCounter--;
if (stepCounter < 0) stepCounter = numSteps - 1;
setOutput(stepCounter);
}

void setOutput(int step)
{
digitalWrite(motorPin1, bitRead(stepsLookup[step], 0));
digitalWrite(motorPin2, bitRead(stepsLookup[step], 1));
digitalWrite(motorPin3, bitRead(stepsLookup[step], 2));
digitalWrite(motorPin4, bitRead(stepsLookup[step], 3));
}
void serialEvent() {
while (Serial.available()) { // chequea si el buffer del puerto serie tiene algun valor, Serial.available() devuelve la cant de datos que hay en el buffer
// get the new byte:
char inChar = (char)Serial.read(); //declara una variable de tipo caracter, lee lo q hay en el buffer y lo guarda en inChar
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
if (inChar == '\n') {
stringComplete = true;

}
}
}

Por favor lee las Normas del foro y edita tu código usando etiquetas </>