#define DIR_PIN 0 #define STEP_PIN 1 void setup() { pinMode(STEP_PIN, OUTPUT); // Set STEP_PIN as an output pinMode(DIR_PIN, OUTPUT); // Set DIR_PIN as an output digitalWrite(STEP_PIN, LOW); // Initialize the step signal as LOW digitalWrite(DIR_PIN, LOW); // Initialize the step signal as LOW } void loop() { digitalWrite(DIR_PIN, HIGH); // Set motor direction to clockwise (CW) for (int i = 0; i < 200; i++) { // Loop 200 times (one full revolution) digitalWrite(STEP_PIN, HIGH); // Set the step signal HIGH (trigger one step) digitalWrite(STEP_PIN, LOW); // Set the step signal LOW (prepare for next step) delay(5); // Wait 5 ms per step (5ms * 200 = 1000ms = 1 second per rotation) } digitalWrite(DIR_PIN, LOW); // Set motor direction to counter clockwise (CCW) for (int i = 0; i < 200; i++) { // Loop 200 times (one full revolution) digitalWrite(STEP_PIN, HIGH); // Set the step signal HIGH (trigger one step) digitalWrite(STEP_PIN, LOW); // Set the step signal LOW (prepare for next step) delay(25); // Wait 5 ms per step (5ms * 200 = 1000ms = 1 second per rotation) } delay(1000); // Wait 1 second before repeating the cycle }