//This is an example of how you would control 1 stepper
#include <AccelStepper.h>
int motorSpeed = 800;//10600; //maximum steps per second (about 3rps / at 16 microsteps)
//int motorAccel = 80000; //steps/second/second to accelerate
int motorDirPin = 2; //digital pin 2
int motorStepPin = 3; //digital pin 3
//set up the accelStepper intance
//the "1" tells it we are using a driver
AccelStepper stepper(AccelStepper::DRIVER, motorStepPin, motorDirPin);
void setup(){
stepper.setMaxSpeed(motorSpeed);
stepper.setSpeed(800);
// stepper.setAcceleration(100000);
//stepper.moveTo(100); //move 32000 steps (should be 10 rev)
}
int i = 1;
void loop(){
if (stepper.distanceToGo() == 0)
{
delay(1000);
stepper.move(2*i);
stepper.setSpeed(600);
i = -1 * i;
}
stepper.runSpeedToPosition();
}