Here's the code that works (again, it's another library):
#include <Arduino.h>
#include "BasicStepperDriver.h"
// Motor steps per revolution. Most steppers are 200 steps or 1.8 degrees/step
#define MOTOR_STEPS 200
#define RPM 120
// Since microstepping is set externally, make sure this matches the selected mode
// If it doesn't, the motor will move at a different RPM than chosen
// 1=full step, 2=half step etc.
#define MICROSTEPS 2
// All the wires needed for full functionality
#define DIR 2
#define STEP 3
//Uncomment line to use enable/disable functionality
//#define ENABLE 13
// 2-wire basic config, microstepping is hardwired on the driver
BasicStepperDriver stepper(MOTOR_STEPS, DIR, STEP);
//Uncomment line to use enable/disable functionality
//BasicStepperDriver stepper(MOTOR_STEPS, DIR, STEP, ENABLE);
void setup() {
stepper.begin(RPM, MICROSTEPS);
}
void loop() {
// energize coils - the motor will hold position
// stepper.enable();
/*
* Moving motor one full revolution using the degree notation
*/
stepper.rotate(7200);
/*
* Moving motor to original position using steps
*/
stepper.move(-720);
// pause and allow the motor to be moved by hand
// stepper.disable();
delay(3000);
}
And this one doesn't (as expected):
#include <AccelStepper.h>
AccelStepper stepper(1,3,2); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
void setup()
{
stepper.setMaxSpeed(1000);
stepper.setSpeed(50);
}
void loop()
{
stepper.runSpeed();
}