Hello! I do this code, maybe to someone it helps.
My question is how I declare to move the motor in the other direction.
thanks
#include <AccelStepper.h>
#define AnchoPulso 1000
// The X Stepper pins
#define STEPPER1_DIR_PIN 3
#define STEPPER1_STEP_PIN 2
#define STEPPER1_ENA_PIN 1
// The Y stepper pins
#define STEPPER2_DIR_PIN 7
#define STEPPER2_STEP_PIN 6
#define STEPPER2_ENA_PIN 5
// Define some steppers and the pins the will use
AccelStepper stepper1(AccelStepper::DRIVER, STEPPER1_STEP_PIN, STEPPER1_DIR_PIN);
AccelStepper stepper2(AccelStepper::DRIVER, STEPPER2_STEP_PIN, STEPPER2_DIR_PIN);
//uint8_t interface = AccelStepper::FULL4WIRE,uint8_t pin1 = 2,uint8_t pin2 = 3,uint8_t pin3 = 4,uint8_t pin4 = 5,bool enable = true)
void setup()
{
digitalWrite(STEPPER1_ENA_PIN, LOW);
digitalWrite(STEPPER2_ENA_PIN, LOW);
//digitalWrite(STEPPER1_DIR_PIN, HIGH);
stepper1.setMaxSpeed(1000.0);
//stepper1.setAcceleration(1000.0);
stepper1.moveTo(1000);
stepper1.setSpeed(1000);
stepper2.setMaxSpeed(1000.0);
//stepper2.setAcceleration(1000.0);
stepper2.moveTo(-1000);
stepper2.setSpeed(1000);
}
void loop()
{
// Change direction at the limits
stepper1.runSpeed();
stepper2.runSpeed();
}