Stepper Motor Revolutions

Hello. How can I make the motor go 3 times? Should I put the code 3 times in a row or is there a shorter better way?

#include <Stepper.h>

const int Rev = 1000;
Stepper S(Rev, 10, 11, 12, 13);

void setup() {
S.setSpeed(20);
}

void loop() {

  S.step(Rev);
  delay(1000);

  S.step(-Rev); //make this line do 3 times?
  delay(1000);
}

What stepper motor do you have?

How many steps per revolution is the stepper motor?

If your motor is the little 28BYJ stepper, this page may be of interest.

28BYJ-48 5V 4-Phase Stepper Step Motor for arduino. It turns 5x per 1000 steps.
I want to make it turn 15x on 1 line of code.

So that is 200 steps per revolution. 15 revolutions is 200 * 15 = 3000 steps.

and?

And what?

I don't know what you want. In the original post you say 3 times then you say 15.

Don't be a troll

1 line of code = make motor turn 5 times look at it. sigh....

I'll just put 3 lines of code. This is a waste

I am not the troll here. I was trying to help. But no more. I am out.
Good luck with your project.

I now see what you want. Read the Stepper library reference. Especially the reference for the step() function.

 S.step(3000);  // 15 turns of a 200 step per rev motor.

But I doubt that your stepper is 200 steps per rev. The 28BYJ motors that I have seen are 2038 steps per revolution of the output shaft.

Thank you

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