Confusion about how to create an Accelstepper instance

# include <AccelStepper.h>
const int dirPin= 3;
const int stepPin=2;
AccelStepper myStepper(1,2,3);
void setup() {
  // put your setup code here, to run once:
  myStepper.setMaxSpeed(1000); // limit the value of setspeed
  myStepper.setSpeed(50);      
}

void loop() {
  // put your main code here, to run repeatedly:
  myStepper.run();
  myStepper.stop();
}

AccelStepper myStepper(1,2,3), the first one on the left means the easy drive mode, and this mode suitable for all types of motor right ?

the doc states it's like this

AccelStepper (
  uint8_t interface=AccelStepper::FULL4WIRE, 
  uint8_t pin1=2, 
  uint8_t pin2=3, 
  uint8_t pin3=4, 
  uint8_t pin4=5, 
  bool enable=true
)

Parameters

[in] interface Number of pins to interface to. Integer values are supported, but it is preferred to use the MotorInterfaceTypesymbolic names. AccelStepper::DRIVER (1) means a stepper driver (with Step and Direction pins). If an enable line is also needed, call setEnablePin() after construction. You may also invert the pins using setPinsInverted(). Caution: DRIVER implements a blocking delay of minPulseWidth microseconds (default 1us) for each step. You can change this with setMinPulseWidth(). AccelStepper::FULL2WIRE (2) means a 2 wire stepper (2 pins required). AccelStepper::FULL3WIRE (3) means a 3 wire stepper, such as HDD spindle (3 pins required). AccelStepper::FULL4WIRE (4) means a 4 wire stepper (4 pins required). AccelStepper::HALF3WIRE (6) means a 3 wire half stepper, such as HDD spindle (3 pins required) AccelStepper::HALF4WIRE (8) means a 4 wire half stepper (4 pins required) Defaults to AccelStepper::FULL4WIRE (4) pins.
[in] pin1 Arduino digital pin number for motor pin 1. Defaults to pin 2. For a AccelStepper::DRIVER (interface==1), this is the Step input to the driver. Low to high transition means to step)
[in] pin2 Arduino digital pin number for motor pin 2. Defaults to pin 3. For a AccelStepper::DRIVER (interface==1), this is the Direction input the driver. High means forward.
[in] pin3 Arduino digital pin number for motor pin 3. Defaults to pin 4.
[in] pin4 Arduino digital pin number for motor pin 4. Defaults to pin 5.
[in] enable If this is true (the default), enableOutputs() will be called to enable the output pins at construction time.

so if you use 1 (or AccelStepper::DRIVER ) as the first parameter you are in this case:

AccelStepper::DRIVER (1) means a stepper driver (with Step and Direction pins)

1 Like

....

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.