# Two stepper motor activated when push button is presses

Hi everyone, i need your help for a project.
My actual part list:
-2 x Nema 17 stepper motor
-2 x drv8825 stepper driver
-arduino uno
-12v DC power supply 10A
-2 push button switch
-2 resistors 10k ohm

I have to program 2 stepper motors so that when a push button is pressed, stepper motor 1 rotates 30degrees (16.66 steps) and then after 1000microseconds stepper motor 2 rotates 90 degree (50).
Then stepper motor 1 rotates 60 degrees (33.33 steps) and after 1000 microseconds stepper motor rotates 90 degrees (50steps).

When push button 2 is pressed, different sequence is done with the motors.

If you can help me on the first sequence, the second will be straight forward.

Anything is additional is required for the project, please let me know.
Thank you so much

Hello, this is quite easy to achieve, but you must realize that you can not move a stepper motor by a fraction of step. Of course you can use microstepping on the driver to approximate as much as you can.

Hi, it does not have to be very accurate. Even if the stepper motor is 31 or 29 degrees, thats ok also. So 16 steps will also be ok. Where can i get the code for this please?

All you need to do is set the DIR pin on the driver to high or low to set the direction of rotation, the pulse the STEP pin to make it turn... a quick search on google for "arduino stepper" will give you about 12.000.000 results including schematics, tutorial and code examples

I did search it on google and youtube. But i want the motor to rotate to a specific angle then completely stop. On google all steppers are in a loop amd continue to rotate.

you just answered yourself: take the part you do not want to be in loop out of loop! something like void move (int numberOfStepsToMove) { .... move the desired number of steps }

then from loop you call move when the button is pressed

Thanks for your help. I have a concept on how it should work but i have no idea on how to put everything together. Coding for me is the hardest part. Thats why i am seeking for help.

please send me a PM if you wish me to write the code for you :)

BOOM90: I did search it on google and youtube. But i want the motor to rotate to a specific angle then completely stop. On google all steppers are in a loop amd continue to rotate.

Seriously. Did you really do any searching yourself? Because that statement is utter nonsense. The first result of "arduino stepper" on Google is unsurprisingly the built-in stepper library. The problem I had with it is that the one thing it CAN'T do is continuous rotation: it takes the number of (micro)steps to take as parameter... which is of course what steppers are most commonly used for, and which incidentally is exactly what you want to do! For that reason the vast majority of stepper projects you will find if you actually take the time to search a bit is projects where steppers are moving for specific amounts of rotation.

To make your life even easier: the stepper library comes with an example where it moves the stepper one way (they do one rotation, that's easy enough to change), and then move it the other way. That's the code example you're looking for.

All of that in the very first Google search result...

believe it or not but i did a lot of research. but what i am after is that the stepper does certain amount of steps, then stops instead of going anti clockwise. But i cant get it out of the loop so that it stops. it is always doing the same amount of steps

Well, that's a matter of programming. Just have it wait for the next button press.

this is where i am confused. What code is needed to tell the motor to wait until the next push button is pressed? it is always stuck in a loop kind of thing

Maybe you simply post your code?