Controlling bipolar stepper motors with time


I am relatively new to this arduino world, so excuse me if I say something dumb xD

I am trying to control two bipolar stepper motors with time. I am using to nema 17 motors (datasheet) and the drivers are tb6560(datasheet).

Basically, this is how i intend it to work, both motors rotate CW during 60 seconds or if they hit a crash sensor they stop and wait until the 60 seconds pass. Then they change direction and rotate CCW during 60 seconds or, again, if they hit crash sensor they stop and wait until the end of the 60 seconds. And just basically do this again and again.

I have seen the simple stepper code, but I am having a hard time translating from the use of the buttons to the use of time. And I have found a lot of this nema 17 stepper motor codes, but a lot of them are so different that I'm not sure what is the correct one, some use libraries, some don't. About the crash sensors I think I can do it, doesn't seem that difficult.

Thank you in advance for any help

What have you tried? And did it come close to what you want?


Haven't really tried anything, I'm a university student and i rarely have access to the components I've just told you about. Besides, Electronics isn't really my field of study, but they demanded it in a project. So, I'm just kind of looking for some guidance.

Thank you for your response Paul

Have a look at how millis() is used to manage timing in Several Things at a Time.

And see Using millis() for timing. A beginners guide if you need more explanation.

Planning and Implementing a Program

Take a step.

Look at the time (flip direction).

Look at the crash sensors.