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