Help with 2 steppermotors controlled by potentiometers

Hi forummembers,

I managed to get my project working. The goal was to control 2 stepper motors separately using potentiometers.
On the display, I needed to see the speed of both motors, ranging from 0-100%.
The speed wasn't crucial. The idea was for motor 2 to spin faster than motor 1 (to stretch a synthetic thread).
In the attachment, you can find my code as well as a link to Wokwi.
All the necessary capacitors and pull-up resistors are mounted in my project. I couldn't draw them in Wokwi.
There are probably still improvements possible.
Feel free to keep me updated.
The dip switches of the tb6600 are set to S1 S2 S3 (6400) Off and S4S5S65 ON (0.5amp).
Sorry for the slow responses, but this was a side project amidst all my other work, so there wasn't much time to reply.

Maybe there are still mistakes, forgive me, it's my second project, I still need to learn some things.

Kind regards

Michel

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <AccelStepper.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

// motor 2

#define directionPin2 2
#define stepPin2 3
#define enPin2 4
#define switchPin1 6  //toggle switch motor 2  on   oranje
#define switchPin2 5  //toggle switch motor 2  off  Bruin
#define potentiometerPin2 A1

AccelStepper stepper2(AccelStepper::DRIVER, stepPin2, directionPin2);

// MOTOR 1

#define directionPin1 7
#define stepPin1 9
#define enPin1 8
#define switchPin3 11  // toggle switch motor 1 on  Blauw
#define switchPin4 10  // toggle switch motor 1 off  Groen
#define potentiometerPin1 A0

AccelStepper stepper1(AccelStepper::DRIVER, stepPin1, directionPin1);

int previousPotValue1 = 0;
int previousPotValue2 = 0;

bool motor1Running = false;
bool motor2Running = false;

void setup() {

  lcd.init();
  lcd.backlight();
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("    Stretcher  ");
  lcd.setCursor(0, 1 );
  lcd.print("Made WE62 Ugent");
  delay(6000);
  lcd.clear();

  lcd.setCursor(0, 0);
  lcd.print("Speed M1: ");
  lcd.setCursor(13, 0);
  lcd.print("  % ");
  lcd.setCursor(0, 1);
  lcd.print("Speed M2: ");
  lcd.setCursor(13, 1);
  lcd.print("  % ");

  pinMode(switchPin1, INPUT);  // Schakelaar 1 heeft een pull-up weerstand
  pinMode(switchPin2, INPUT);  // Schakelaar 2 heeft een pull-up weerstand
  pinMode(switchPin3, INPUT);  // Schakelaar 3 heeft een pull-up weerstand
  pinMode(switchPin4, INPUT);  // Schakelaar 4 heeft een pull-up weerstand

  pinMode(directionPin1, OUTPUT);
  pinMode(stepPin1, OUTPUT);
  pinMode(enPin1, OUTPUT);

  digitalWrite(directionPin1, HIGH);
  digitalWrite(enPin1, HIGH);

  pinMode(directionPin2, OUTPUT);
  pinMode(stepPin2, OUTPUT);
  pinMode(enPin2, OUTPUT);

  digitalWrite(directionPin2, LOW);
  digitalWrite(enPin2, HIGH);

  digitalWrite(switchPin1, LOW);  // Schakelaar 1 heeft een pull-up weerstand
  digitalWrite(switchPin2, LOW);  // Schakelaar 1 heeft een pull-up weerstand
  digitalWrite(switchPin3, LOW);  // Schakelaar 1 heeft een pull-up weerstand
  digitalWrite(switchPin4, LOW);  // Schakelaar 1 heeft een pull-up weerstand

  stepper1.setMaxSpeed(4000);  // Set max speed in steps per second
  stepper2.setMaxSpeed(4000);

  stepper1.setAcceleration(500);  // Set acceleration in steps per second^2
  stepper2.setAcceleration(500);

  stepper1.setCurrentPosition(0);
  stepper2.setCurrentPosition(0);
}

void updateLCD(float speedPercent, int motor) {
  lcd.setCursor(10, motor);
  lcd.print(speedPercent, 0);
  lcd.print(" ");
}

void loop() {

  // Controleer de status van de toggle switches voor motor 2
  if (digitalRead(switchPin1) == HIGH) {  // start motor 2
    motor2Running = true;
    digitalWrite(enPin2, LOW);

  } else if (digitalRead(switchPin2) == HIGH) {  // start motor 2
    motor2Running = false;
    Serial.println(switchPin2);
    digitalWrite(enPin2, HIGH);
  }

  // Controleer de status van de toggle switches voor motor 1
  if (digitalRead(switchPin3) == HIGH) {  // start motor 1
    motor1Running = true;
    digitalWrite(enPin1, LOW);

  } else if (digitalRead(switchPin4) == HIGH) {  // stop motor 1
    digitalWrite(enPin1, HIGH);
    motor1Running = false;
  }

  // Steppermotor 1
  if (motor1Running) {
    int potValue1 = analogRead(potentiometerPin1);
    float speedPercent1 = map(potValue1, 0, 1023, 100, 1);
    if (abs(potValue1 - previousPotValue1) > 10) {
      updateLCD(speedPercent1, 0);
      previousPotValue1 = potValue1;
    }
    int speed1 = map(potValue1, 1023, 0, 0, 4000);  // Map potentiometer value to speed
    stepper1.setSpeed(speed1);
    stepper1.runSpeed();
  } else {
    stepper1.stop();
  }

  // Stepper motor 2
  if (digitalRead(switchPin2) == LOW) {
    int potValue2 = analogRead(potentiometerPin2);
    float speedPercent2 = map(potValue2, 0, 1023, 100, 1);
    if (abs(potValue2 - previousPotValue2) > 10) {
      updateLCD(speedPercent2, 1);
      previousPotValue2 = potValue2;
    }
    int speed2 = map(potValue2, 1023, 0, 0, 4000);  // Map potentiometer value to speed
    stepper2.setSpeed(speed2);
    stepper2.runSpeed();
  } else {
    stepper2.stop();
  }
}