Controlling the stepper motor

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
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++) {


loop runs over and over again. Each loop steps 25600.
If the motor would stop after 25600 steps, what would make it start again?

At the end of the sketch, replace:



while(1); // Press reset button to continue

oh i get it now, the number of steps dictate the number of steps in one revolution, But then again, if i only want a half rotation or a quarter rotation, how do i go about doing so?

I get it now, the number of steps = the number of steps in one rotation. How do I go about controlling the rotation of the motor? lets say I only want a half rotation?

What are you trying to do? If you really want to do a single rotation at power up, move your stepper code into setup. I'd guess that there's going to be more to come though.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.