/*
Stepper tracks pot
The position of the stepper matches the degree of the pot.
*/
#include <AccelStepper.h>
const int ANALOG_IN = A0;
// AccelStepper myStepper(AccelStepper::DRIVER, stepPin, dirPin);
AccelStepper stepper(AccelStepper::DRIVER, 3, 2);
void setup() {
stepper.setMaxSpeed(1000);
}
void loop() {
int val = analogRead(ANALOG_IN);
int mappedVal = map(val, 0, 1023, -75, 75); // 75 * 1.8 deg/step = +/-135°
stepper.moveTo(mappedVal);
stepper.setSpeed(100);
stepper.runSpeedToPosition();
}