Istruzioni microstep driver ST-4045-A1

Buonasera a tutti, sono riuscito a far funzionare il driver (ST-4045-A1), tramite le uscite PWM di arduino.

int motorPin1 = 8;
int motorPin2 = 9;
int motorPin3 = 10;
int motorPin4 = 11;
 
void setup() {
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
   

}
 
void loop() {

digitalWrite(motorPin1, LOW);
delay (3);
digitalWrite(motorPin2, HIGH);
delay (3);
digitalWrite(motorPin3, LOW);
delay (3);
digitalWrite(motorPin4, HIGH);
delay (3);
digitalWrite(motorPin1, HIGH);
delay (3);
digitalWrite(motorPin2, LOW);
delay (3);
digitalWrite(motorPin3, HIGH);
delay (3);
digitalWrite(motorPin4, LOW);

}

Volendo spingermi oltre, mi piacerebbe poter variare velocità e la coppia mantenendo sempre attivo il motore.
Nell' esempio riportato di seguito la velocità è variabile e il motore non è sempre attivo.

// include stepper library
#include <Stepper.h>

const int stepsPerRevolution = 200;  // Nema17 motor has 200 steps in 360 degrees rotation

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);  // pins 8,9 go to PULL+ & PULL- , pins 10,11 go to DIR+ & DIR-

int tracknumber = 2;  // SET HOW MANY TRACKS YOU WANT UP AND BACK
int trackdistance = 20000;

int actualtracknumber = 0; // current track number

int motiondirection = 2;   // set initial forward motor increments.
int forwardsincrement = 2; // forward
int backwardsincrement = -2; // backwards

int moves = 0;            // current move number
int goforit = 1;         // start or stop the move ?

int topspeed = 3201;  // TOP SPEED OF TRACKING
int bottomspeed = 1;   // start and end speed of RAMP up/down

int benspeed = 1;     // current speed

void setup() {
  
 //  do some setup here
 
  }

void loop() {

    if (goforit == 1) 
  {
  moveit();
  }

    else
  {
  donothing();
  }
  }

void moveit()

{

   int x = 1;
   for (int i = 50; i > -1; i = i + x ) {
      
      if (i >= topspeed) 
      {
      topspeedhold();    // hold top speed for trackdistance variable
      x = -1;            // switch direction at peak
      }
      
      if (i <= bottomspeed)
      { 
      x = +1; // switch direction at troff
      moves++;
      actualtracknumber++; 
      }
        
    int benspeed=i;
      myStepper.setSpeed(benspeed);
      myStepper.step(motiondirection);
      
       if (moves >=1) motiondirection = backwardsincrement; // switch direction 
       if (moves >=2) motiondirection = forwardsincrement , moves = 0;
       if (actualtracknumber >= tracknumber * 2 )  // when the motor has done forward and back the TRACKNUMBER amount set then back to void();
       { 
       goforit = 0;
       return;
       }
     }
}

void topspeedhold()   // hold top speed for trackdistance variable
{
 int f = 1;
   for (int f = 50; f > -1; f = f + 1 ) {
         
      if (f >= trackdistance) 
      {
      return;
      }
      
      myStepper.setSpeed(topspeed);
      myStepper.step(motiondirection);
   }
}

void donothing()
{
while(1);
}

Se qualcuno può indicarmi un link in italiano o spiegarmi il funzionamento di ogni singola istruzione.
Grazie