#include <Stepper.h> #include <AFMotor.h> int enA = 3; int enB = 11; int dirA = 12; int dirB = 13; const int stepsPerRevolution = 400; Stepper myStepper(stepsPerRevolution, dirA, dirB); AF_Stepper motor1(400,1); AF_Stepper motor2(400,2); void forwardstep1() { motor1.onestep(FORWARD,SINGLE); } void backwardstep1() { motor1.onestep(BACKWARD,SINGLE); } void forwardstep2() { motor2.onestep(FORWARD,SINGLE); } void backwardstep2() { motor2.onestep(BACKWARD,SINGLE); } void setup() { myStepper.setSpeed(60); pinMode(enA, OUTPUT); digitalWrite (enA, HIGH); pinMode(enB, OUTPUT); digitalWrite (enB, HIGH); motor1.setSpeed(10); motor2.setSpeed(20); } void loop() { motor2.step(2400,BACKWARD,SINGLE); delay(1000); myStepper.step(stepsPerRevolution*35); delay(2000); motor2.step(2400,FORWARD,SINGLE); delay(1000); motor1.step(100,FORWARD,SINGLE); delay(1000); motor2.step(2400,BACKWARD,SINGLE); delay(1000); myStepper.step(-stepsPerRevolution*35); delay(2000); motor2.step(2400,FORWARD,SINGLE); delay(1000); motor1.step(100,FORWARD,SINGLE); delay(1000); }