// First stepper motor control pins
const int stepPin1 = 2;  // STEP pin for first motor
const int dirPin1 = 3;   // DIR pin for first motor
const int enPin1 = 4;    // EN pin for first motor (optional)

// Second stepper motor control pins
const int stepPin2 = 5;  // STEP pin for second motor
const int dirPin2 = 6;   // DIR pin for second motor
const int enPin2 = 7;    // EN pin for second motor (optional)

void setup() {
  // Initialize first motor pins
  pinMode(stepPin1, OUTPUT);
  pinMode(dirPin1, OUTPUT);
  pinMode(enPin1, OUTPUT); // Optional
  digitalWrite(enPin1, LOW); // Enable driver (active low)
  digitalWrite(dirPin1, HIGH); // Set initial direction for first motor

  // Initialize second motor pins
  pinMode(stepPin2, OUTPUT);
  pinMode(dirPin2, OUTPUT);
  pinMode(enPin2, OUTPUT); // Optional
  digitalWrite(enPin2, LOW); // Enable driver (active low)
  digitalWrite(dirPin2, HIGH); // Set initial direction for second motor
}

void loop() {
  // Control first motor (clockwise rotation)
  digitalWrite(dirPin1, HIGH); // Set direction to clockwise
  for (int i = 0; i < 200; i++) { // 200 steps for one full revolution (adjust as needed)
    digitalWrite(stepPin1, HIGH);
    delayMicroseconds(800); // Adjust delay as needed for your motor speed
    digitalWrite(stepPin1, LOW);
    delayMicroseconds(800); // Adjust delay as needed for your motor speed
  }

  // Control second motor (clockwise rotation)
  digitalWrite(dirPin2, LOW); // Set direction to clockwise
  for (int i = 0; i < 200; i++) { // 200 steps for one full revolution (adjust as needed)
    digitalWrite(stepPin2, HIGH);
    delayMicroseconds(800); // Adjust delay as needed for your motor speed
    digitalWrite(stepPin2, LOW);
    delayMicroseconds(800); // Adjust delay as needed for your motor speed
  }
  delay(1000); // Delay between directions

  // Control first motor (anticlockwise rotation)
  digitalWrite(dirPin1, LOW); // Set direction to anticlockwise
  for (int i = 0; i < 200; i++) { // 200 steps for one full revolution (adjust as needed)
    digitalWrite(stepPin1, HIGH);
    delayMicroseconds(800); // Adjust delay as needed for your motor speed
    digitalWrite(stepPin1, LOW);
    delayMicroseconds(800); // Adjust delay as needed for your motor speed
  }

  // Control second motor (anticlockwise rotation)
  digitalWrite(dirPin2, HIGH); // Set direction to anticlockwise
  for (int i = 0; i < 200; i++) { // 200 steps for one full revolution (adjust as needed)
    digitalWrite(stepPin2, HIGH);
    delayMicroseconds(800); // Adjust delay as needed for your motor speed
    digitalWrite(stepPin2, LOW);
    delayMicroseconds(800); // Adjust delay as needed for your motor speed
  }
  delay(1000); // Delay between directions
}
A4988
A4988