/ Define pin connections & motor's steps per revolution // Pins for original board // Dir: D8 (GPIO7), Step: D7 (GPIO44) // Steps per revolution: 3200 (due to microstepping) const int dirPin = 7; const int stepPin = 44; const int stepsPerRevolution = 3200; void setup() { // Declare pins as Outputs pinMode(stepPin, OUTPUT); pinMode(dirPin, OUTPUT); } void loop() { // Set motor direction clockwise digitalWrite(dirPin, HIGH); // Spin motor slowly for(int x = 0; x < stepsPerRevolution; x++) { digitalWrite(stepPin, HIGH); delayMicroseconds(200); digitalWrite(stepPin, LOW); delayMicroseconds(200); } delay(1000); // Wait a second // Set motor direction counterclockwise digitalWrite(dirPin, LOW); // Spin motor quickly for(int x = 0; x < stepsPerRevolution; x++) { digitalWrite(stepPin, HIGH); delayMicroseconds(100); digitalWrite(stepPin, LOW); delayMicroseconds(100); } delay(1000); // Wait a second }