#include <ContinuousStepper.h>
const uint8_t stepPin = 2;
const uint8_t dirPin = 3;
const uint8_t potPin = A0;
const uint16_t potReadInterval = 500; // in milliseconds
ContinuousStepper stepper;
void setup() {
stepper.begin(stepPin, dirPin);
}
void loop() {
static unsigned long lastPotReadTime = 0;
unsigned long currentTime = millis();
if (currentTime - lastPotReadTime >= potReadInterval) {
int potValue = analogRead(potPin);
int stepperSpeed = map(potValue, 0, 1023, -1000, 1000);
stepper.spin(stepperSpeed);
lastPotReadTime = currentTime;
}
stepper.loop();
}