// Define pin numbers const int dirPin = 1; // direction const int stepPin = 2; // step const int enaPin = 3; // enable 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 with few us delay -> fast for (int x = 0; x < 1000; x++) { // Generate a pulse digitalWrite(stepPin, HIGH); delayMicroseconds(400); digitalWrite(stepPin, LOW); delayMicroseconds(400); } delay(1000); // Wait for a second // Perform 1000 steps with intermediate us delay -> medium for (int x = 0; x < 1000; x++) { // Generate a pulse digitalWrite(stepPin, HIGH); delayMicroseconds(800); digitalWrite(stepPin, LOW); delayMicroseconds(800); } delay(1000); // Wait for a second // Perform 1000 steps with many us delay -> slow for (int x = 0; x < 1000; x++) { // Generate a pulse digitalWrite(stepPin, HIGH); delayMicroseconds(1200); digitalWrite(stepPin, LOW); delayMicroseconds(1200); } delay(1000); // Wait for a second }