Running 2 Steppers Synchronously


so may misunderstanding on part, attempting move 2 separate motors synchronously, @ same time.

i found arduino stepper library, , looked function provides , implemented mystepper.step(##) (##=number of steps) function library includes, when read description of line, said "blocking", in not give control next line until finishes.

so potential misunderstanding here is:

if put 2 lines of above mentioned function (mystepper.step(##)), 1 right after other, both motors run? or 1 run other? if latter true, how run both? put both step commands on same line?

here snippet of code trying write:

#include<stepper.h>
stepper motor1=stepper(48,4,5);
stepper motor2=stepper(48,6,7);
stepper motor3=stepper(48,8,9);
stepper motor4=stepper(48,10,11);
char val;
void setup()
{
  motor1.setspeed(30);
  motor2.setspeed(30);
  motor3.setspeed(30);
  motor4.setspeed(30);
  serial.begin(9600);
}

void loop()
{
  val='still';
  if(serial.available())
  {
    val=serial.read();
  }
  if(val=='forward')
  {
    motor1.step(24); //right here confused.
    motor2.step(24);
  }
  if(val='backward')
  {
   
}

yes, run 1 motor , other. 

if want run them both @ same time you'll have go 1 step @ time.  or write own library non-blocking functions so, may little tough novice.


Arduino Forum > Using Arduino > Programming Questions > Running 2 Steppers Synchronously


arduino

Comments