two step motors running at the same time

I am making a simple clock, I am 3d printing most of the parts needed. I am not very good at programing but need to have two motors running at the same time at different speeds. As of now I can get both of them to move but they switch off turning. Can anyone help me get both of them to move at the same time?

#include <Stepper.h>

#define STEPS_PER_MOTOR_REVOLUTION 32

#define STEPS_PER_OUTPUT_REVOLUTION 32 * 64 //2048

Stepper smal_stepper(STEPS_PER_MOTOR_REVOLUTION, 4, 5, 6, 7);
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);

int Steps2Take;

void setup() {
Steps2Take = STEPS_PER_OUTPUT_REVOLUTION / 2; // Rotate CW 1/2 turn
small_stepper.setSpeed(100);
small_stepper.step(Steps2Take);
delay(0);

}

void loop() {
// put your main code here, to run repeatedly:

Steps2Take = STEPS_PER_OUTPUT_REVOLUTION / 2; // Rotate CW 1/2 turn
smal_stepper.setSpeed(100);
smal_stepper.step(Steps2Take);
delay(0);

}

  1. put your code in code tags (highlight your code, then click the </> button)

Anyway, what do you mean they switch off turning. Do you mean they stop turning or that they take turns turning? If the latter, then in loop() you are only turning "smal_stepper" and not "small_stepper". (BTW, that is terrible naming, just do smallStepper1 and smallStepper2...)

You probably need to move each motor 1 step at a time rather than asking the library to move them for multiple steps. Then use your own code to cause the correct number of steps to happen.

...R
Stepper Motor Basics

Hi,
How have you got your steppers connected to the arduino?
How are you powering the arduino and the steppers?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

What arduino do you have?

Tom.... :slight_smile: