Hi
I'm having some trouble with a little stepper motor setup I have.
I need stepper2 to go in the opposite direction and I thought I just put a negative value instead. But it keeps going in the same direction. I've tried negative values all over the place and switched the pinning around, but I can't get it to work.
My steppers are called 28YBJ-48.
Any help is much appreciated.
#include <AccelStepper.h>
#define HALFSTEP 4
#define motorPin1 4
#define motorPin2 5
#define motorPin3 6
#define motorPin4 7
#define motorPin5 8
#define motorPin6 9
#define motorPin7 10
#define motorPin8 11
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin2, motorPin3, motorPin4);
AccelStepper stepper2(HALFSTEP, motorPin5, motorPin6, motorPin7, motorPin8);
const int buttonPin = 2;
int buttonState = 0;
void setup() {
stepper1.setMaxSpeed(250.0);
stepper1.setAcceleration(50.0);
stepper1.move(1);
stepper2.setMaxSpeed(3.0);
stepper2.setAcceleration(50.0);
stepper2.move(-1);
pinMode(buttonPin,INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == LOW){
stepper1.move(70000);
stepper2.move(1000);
}
stepper1.run();
stepper2.run();
}