// Define pin numbers const int dirPin = 1; // direction const int stepPin = 2; // step const int enaPin = 3; // enable const int delay_us = 320; //duration of HIGH and LOW phase: min. 320; max. 2000 void setup() { // Define all pins at output pinMode(stepPin, OUTPUT); pinMode(dirPin, OUTPUT); pinMode(enaPin, OUTPUT); // Enable the motor driver digitalWrite(enaPin, LOW); // Set the rotation to one particular direction digitalWrite(dirPin, HIGH); } void loop() { // Perform 1000 steps for (int x = 0; x < 400; x++) { // Generate a pulse digitalWrite(stepPin, HIGH); delayMicroseconds(delay_us); // The HIGH phase of a pulse cannot be as long digitalWrite(stepPin, LOW); delayMicroseconds(delay_us); // A hugh delay for lower speed in the LOW phase } delay(1000); // Wait for a second }