#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
// This defines the analog input pin for reading the control voltage
// Tested with a 10k linear pot between 5v and GND
const byte PositionPot = A0;
const byte AccelerationPot = A1;
int current = 0;
int current2 = 0;
void setup()
{
stepper.setMaxSpeed(100);
stepper.setAcceleration(15);
}
void loop()
{
// Read new position
int analog_in = analogRead(PositionPot);
//stepper.setAcceleration(analogRead(AccelerationPot));
if (analog_in > 1023/2 + 200){
current = analog_in;
stepper.moveTo(current);
//stepper.step(1);
stepper.run();
}
if (analog_in < 1023/2 - 200){
current2 = analog_in;
stepper.moveTo(current2);
//stepper.step(-1);
stepper.run();
}
}