// Define motor control pins const int stepPin = 0; // Connect to STEP pin on driver const int dirPin = 1; // Connect to DIRECTION pin on driver const int stepsPerRevolution = 200; // Number of steps per full revolution for your motor void setup() { pinMode(stepPin, OUTPUT); pinMode(dirPin, OUTPUT); Serial.begin(921600); } void loop() { // Rotate clockwise one full revolution digitalWrite(dirPin, HIGH); // Set direction clockwise Serial.println("Clockwise"); for (int i = 0; i < stepsPerRevolution; i++) { digitalWrite(stepPin, HIGH); delayMicroseconds(1000); // Adjust speed by changing delay time digitalWrite(stepPin, LOW); delayMicroseconds(1000); } delay(1000); // Pause 1 second // Rotate counterclockwise one full revolution digitalWrite(dirPin, LOW); // Set direction counterclockwise Serial.println("Counter-Clockwise"); for (int i = 0; i < stepsPerRevolution; i++) { digitalWrite(stepPin, HIGH); delayMicroseconds(1000); digitalWrite(stepPin, LOW); delayMicroseconds(1000); } delay(1000); // Pause 1 second }