#define stepPin1 5
#define dirPin1 2
#define stepPin2 10
#define dirPin2 8
void setup() {
// Sets the two pins as Outputs
pinMode(stepPin1,OUTPUT);
pinMode(dirPin1,OUTPUT);
pinMode(stepPin2,OUTPUT);
pinMode(dirPin2,OUTPUT);
}
void loop() {
digitalWrite(dirPin1,HIGH); // Enables the motor to move in a particular direction
digitalWrite(dirPin2,LOW); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 500000; x++) {
digitalWrite(stepPin1,HIGH);
delayMicroseconds(300); // by changing this time delay between the steps we can change the rotation speed
digitalWrite(stepPin1,LOW);
delayMicroseconds(300);
digitalWrite(stepPin2,HIGH);
delayMicroseconds(300); // by changing this time delay between the steps we can change the rotation speed
digitalWrite(stepPin2,LOW);
delayMicroseconds(300);
}
delay(1000); // One second delay
digitalWrite(dirPin1,LOW);
digitalWrite(dirPin2,LOW); //Changes the rotations direction
// Makes 400 pulses for making two full cycle rotation
for(int x = 0; x < 5367238; x++) {
digitalWrite(stepPin1,HIGH);
delayMicroseconds(300);
digitalWrite(stepPin1,LOW);
delayMicroseconds(300);
digitalWrite(stepPin2,HIGH);
delayMicroseconds(300);
digitalWrite(stepPin2,LOW);
delayMicroseconds(300);
}
delay(1000);
}