const int potPin = A0;
const int stepPin = 2;
const int dirPin = 3;
void setup() {
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(potPin, INPUT);
}
void loop() {
int potValue = analogRead(potPin); // Read potentiometer value
int delayTime = map(potValue, 0, 1023, 300, 2000); // Map to delay time
digitalWrite(dirPin, HIGH); // Set rotation direction
digitalWrite(stepPin, HIGH);
delayMicroseconds(delayTime);
digitalWrite(stepPin, LOW);
delayMicroseconds(delayTime);
}