Hello, I am trying to control the stepper motor to a desired revolution. I am currently using micro stepping mode, and there are 51200 steps per revolution.
I want to do a half rotation, which is 25600 steps? i tried running the code, but the motor just moves continuously with a smaller step, how can I make it stop after doing a half rotation?
I tried tweaking the steps, but the motor just runs continuously, how am I able to do a quater/half rotation? & stop there
// defines pins numbers
const int stepPin = 3;
const int dirPin = 4;
const int ms1 = 7;
const int ms2 = 6;
const int ms3 = 5;
void setup() {
// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(ms1,OUTPUT);
pinMode(ms2,OUTPUT);
pinMode(ms3,OUTPUT);
}
void loop() {
digitalWrite(dirPin,LOW); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 25600; x++) {
digitalWrite(ms1,HIGH);
digitalWrite(ms2,HIGH);
digitalWrite(ms3,HIGH);
digitalWrite(stepPin,LOW);
delayMicroseconds(1500);
digitalWrite(stepPin,HIGH);
delayMicroseconds(1500);
}
delay(1000);
}