Motorshield V1.2 + 28BYJ-48 Stepper

Hey I have a question. I have a Motorshield V1.2 + 28BYJ-48 Stepper.

I connected them following:

Motor---Shield
Red Wire -GND
Orange - Top clamp M1
Yellow - Bottom Clamp M2
Pink -Bottom Clamp M1
Blue - Top Clamp M2

With the followed code that I have from AdaFruit

Skip to content
Features
Business
Explore
Marketplace
Pricing
This repository
Search
Sign in or Sign up
60 216 181 adafruit/Adafruit-Motor-Shield-library
 Code  Issues 6  Pull requests 0  Projects 0  Insights
Adafruit-Motor-Shield-library/examples/AFMotor_MultiStepper/AFMotor_MultiStepper.pde
d2ffa19  on 23 Feb 2011
@ladyada ladyada added accelstepper examples, fixed casting problem for stepper timing
     
57 lines (48 sloc)  1.41 KB
// MultiStepper
// -*- mode: C++ -*-
//
// Control both Stepper motors at the same time with different speeds
// and accelerations. 
// Requires the AFMotor library (https://github.com/adafruit/Adafruit-Motor-Shield-library)
// And AccelStepper with AFMotor support (https://github.com/adafruit/AccelStepper)
// Public domain!

#include <AccelStepper.h>
#include <AFMotor.h>

// two stepper motors one on each port
AF_Stepper motor1(200, 1);
AF_Stepper motor2(200, 2);

// you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
// wrappers for the first motor!
void forwardstep1() {  
  motor1.onestep(FORWARD, SINGLE);
}
void backwardstep1() {  
  motor1.onestep(BACKWARD, SINGLE);
}
// wrappers for the second motor!
void forwardstep2() {  
  motor2.onestep(FORWARD, SINGLE);
}
void backwardstep2() {  
  motor2.onestep(BACKWARD, SINGLE);
}

// Motor shield has two motor ports, now we'll wrap them in an AccelStepper object
AccelStepper stepper1(forwardstep1, backwardstep1);
AccelStepper stepper2(forwardstep2, backwardstep2);

void setup()
{  
    stepper1.setMaxSpeed(200.0);
    stepper1.setAcceleration(100.0);
    stepper1.moveTo(24);
    
    stepper2.setMaxSpeed(300.0);
    stepper2.setAcceleration(100.0);
    stepper2.moveTo(1000000);
    
}

void loop()
{
    // Change direction at the limits
    if (stepper1.distanceToGo() == 0)
	stepper1.moveTo(-stepper1.currentPosition());
    stepper1.run();
    stepper2.run();
}

But it dosnot work what am I doing wrong??

Are you sure that code and that motor shield are intended to work with a 28BYJ motor? The usual driver for those motors is a ULN2003.

...R

it functions but i can not change the distance with a variable. for exemmple whe n it sees a blue tap it turns left. and it allways runs just one cycle and then stops working.