Need help about using two stepper motors(28BYJ-48)

hello all, I use customstepper library and I am trying to run 2 step motor , I want to run the motors together with delay(5000);

this is example for 1 motor , this is working

#include <CustomStepper.h>

CustomStepper stepper1(6, 7, 8, 9);

boolean rotatedeg = false;
void setup()
{
stepper1.setRPM(12);
stepper1.setSPR(4075.7728395);
}

void loop()
{
if (stepper1.isDone() && rotatedeg == false){

stepper1.setDirection(CCW);
stepper1.rotateDegrees(45);
rotatedeg = true;

}

stepper1.run();
}

this is example for 2 motors code isnt working

#include <CustomStepper.h>

CustomStepper stepper(2, 3, 4, 5);
CustomStepper stepper1(6, 7, 8, 9);
boolean rotatedeg = false;

void setup()
{
stepper.setRPM(12);
stepper.setSPR(4075.7728395);
stepper1.setRPM(12);
stepper1.setSPR(4075.7728395);
}

void loop()
{
if (stepper.isDone() && rotatedeg == false)
{
stepper.setDirection(CW);
stepper.rotateDegrees(15);
rotatedeg = true;
}

stepper.run();

if (stepper1.isDone() && rotatedeg == false){

stepper1.setDirection(CCW);
stepper1.rotateDegrees(45);
rotatedeg = true;

}

stepper1.run();
}

I couldnt run two motors together , can you help me?
here is customstepper library : http://playground.arduino.cc/Main/CustomStepper

I couldnt run two motors together

I don't see where you are trying to. I see that you are trying to run two steppers one at a time.

I do not understand numbering one instance, but not both, of the CustomStepper class. I do not understand the purpose of the rotatedeg variable. In particular, I do not see how you can use one variable to meaningfully, control the position of two steppers.

I can move the two steppers with angular but they work in same time , how can i add delay() function for them , i tried delay but it is not working .

#include <CustomStepper.h>

CustomStepper stepper(2, 3, 4, 5);
CustomStepper stepper1(6, 7, 8, 9);
boolean rotatedeg = false;
boolean rotatedeg1= false;
float x=0,y=0;

void setup()
{
  
  stepper.setRPM(12);
  stepper.setSPR(4075.7728395);
  stepper1.setRPM(12);
  stepper1.setSPR(4075.7728395);
  
  
}

void loop()
{
 
  if (stepper.isDone() && rotatedeg == false  )
  {
    stepper.setDirection(CW);
    stepper.rotateDegrees(30);
    rotatedeg = true;
    x+=30;
     }
    
   
 if (stepper1.isDone() && rotatedeg1 == false ){
    
    stepper1.setDirection(CW);
    stepper1.rotateDegrees(90);
    rotatedeg1 = true;
    y+=90;
   
 }
 stepper.run();
 //delay(2500);
  stepper1.run(); 
}

I can move the two steppers with angular but they work in same time

I really do not understand what you are trying to say.

Do you want one stepper to complete a move (a series of steps) before the other one starts to execute a move?

I use customstepper library

A link would be useful.

I have project a self-adjusting rearview mirror, I use two step motors(28byj-48) for rotating mirror in two axis , In the above code I can rotate the motors angular .However , I need to put a delay between the run times of two motors.Delay function doesnt work in customstepper library , What can I use instead of the delay function? Could you help about it , Paul.

customstepper library link

http://playground.arduino.cc/Main/CustomStepper

However , I need to put a delay between the run times of two motors.Delay function doesnt work in customstepper library

I can't imagine why delay() wouldn't work, IF you use it properly.

I still can not tell what you want, because you did not answer my question. Do you want one motor to start stepping, take all the required steps, and stop, before the other motor starts stepping, takes the required number of steps, and stops?

PaulS: I still can not tell what you want, because you did not answer my question. Do you want one motor to start stepping, take all the required steps, and stop, before the other motor starts stepping, takes the required number of steps, and stops?

yes it is right , one motor start stepping and take all required steps then stop before other motor start stepping,takes the required number of steps then stops.

jwoo: yes it is right , one motor start stepping and take all required steps then stop before other motor start stepping,takes the required number of steps then stops.

So, you are not writing the code that way. You are writing the code so both motors move at the same time.

The library includes an isDone() method, that you could use to make one motor complete it's sequence of steps before the next one starts:

void loop()
{
   if(!rotateDeg)
   {
       stepper.setDirection(CW);
       stepper.rotateDegrees(30);
       rotatedeg = true;
       x+=30;
   }

   while(!stepper.isDone)
   {
      stepper.run();
   }

   // Now, do the same for the other stepper
}

I do not see the purpose of x and y in your code, but I left them in, anyway.

code is working perfect , Ty Paul...

void loop()
{

   if(!rotatedeg)
   {
       stepper.setDirection(CW);
       stepper.rotateDegrees(10);
       rotatedeg = true;
        x+=10;
   }

   while(!stepper.isDone())
   {
      stepper.run();
   }

   // Now, do the same for the other stepper

  if(!rotatedeg1)
   {
       stepper1.setDirection(CW);
       stepper1.rotateDegrees(20);
       rotatedeg1 = true;
       y+=20;
   }

   while(!stepper1.isDone())
   {
      stepper1.run();
   }

referance(x,y); void referance(float x, float y){

if (stepper.isDone() && rotatedeg == false ) { stepper.setDirection(CCW); stepper.rotateDegrees(x); rotatedeg = true; x-=10; }

if (stepper1.isDone() && rotatedeg1 == false ){

stepper1.setDirection(CW); stepper1.rotateDegrees(y); rotatedeg1 = true; y-=20;

} stepper.run(); stepper1.run(); }

x and y for my reference point , my aim is driver will seat the car and mirror will be (x,y) =(0,0) there will be distance sensor and mirror move in two axis according to driver's distance, for example it will move (x,y) = (30 , 45) degrees after that mirror will return to reference point,for this im trying to write a function something like that above