// Sketch by R. Jordan Kreindler, written September 2016, // to rotate a stepper motor using the Wave Drive Method int aPin = 2; //IN1: first end of the blue and yellow stator coil int bPin = 3; //IN2: first end of the pink and orange stator coil int aPrimePin = 4; //IN3: second end of the blue and yellow stator coil int bPrimePin = 5; //IN4: second end of the pink and orange stator coil // We do not connect IN5, IN6, or IN7 int delay1 = 75; 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. 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 // 3. 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 // 4. Reverse current direction and energize the pink 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 }