// Sketch by R. Jordan Kreindler, written September 2016, // to rotate a NEMA stepper motor clockwise using the Wave Drive Method int aPin = 5; //IN1: first end of the blue and yellow stator coil int bPin = 4; //IN2: first end of the white and orange stator coil int aPrimePin = 3; //IN3: second end of the blue and yellow stator coil int bPrimePin = 2; //IN4: second end of the White and orange stator coil // We do not connect IN5, IN6, or IN7 int delay1 = 10; void setup() { // Set all pins as output to send output signals from the Arduino // UNO to the coil windings of the stator pinMode(aPin, OUTPUT); pinMode(bPin, OUTPUT); pinMode(aPrimePin, OUTPUT); pinMode(bPrimePin, OUTPUT); // Start with all coils off digitalWrite(aPin, LOW); digitalWrite(bPin, LOW); digitalWrite(aPrimePin, LOW); digitalWrite(bPrimePin, LOW); } void loop() { // Send current to the apin, and then the bpin // then reverse the current and send reversed current // to aPrimePin and then bPrimePin. // 1. Energize the blue yellow stator coil digitalWrite(aPin, HIGH); digitalWrite(bPin, LOW); digitalWrite(aPrimePin, LOW); digitalWrite(bPrimePin, LOW); // Allow some delay between energizing the coils to allow // the stepper rotor time to respond. delay(delay1); // So, delay1 microseconds // 2. Reverse current direction and energize the blue yellow stator coil digitalWrite(aPin, LOW); digitalWrite(bPin, LOW); digitalWrite(aPrimePin, HIGH); digitalWrite(bPrimePin, LOW); // Allow some delay between energizing the coils to allow // the stepper rotor time to respond. delay(delay1); // So, delay1 microseconds // 3. Energize the blue yellow stator coil digitalWrite(aPin, LOW); digitalWrite(bPin, HIGH); digitalWrite(aPrimePin, LOW); digitalWrite(bPrimePin, LOW); // Allow some delay between energizing the coils to allow // the stepper rotor time to respond. delay(delay1); // So, delay1 microseconds // 4. Reverse current direction and energize the white orange stator coil digitalWrite(aPin, LOW); digitalWrite(bPin, LOW); digitalWrite(aPrimePin, LOW); digitalWrite(bPrimePin, HIGH); // Allow some delay between energizing the coils to allow // the stepper rotor time to respond. delay(delay1); // So, delay1 microseconds }