Seems to be a problem with the map function - I never saw really low values. I tried, and without Serial.print it got faster, but not as fast as expected. If you omit the mapping ist goes the other way round ( regarding the potentiometer ), but much faster.
There is an example 'minimumStepper' which can easily be extended to your potentiometer variant:
/* ====== minimumStepper =======================================
* Bare minimum to get a stepper with step/dir driver turning
*/
#include <MobaTools.h>
// Stepper connections - Please adapt to your own needs.
const byte stepPin = 3;
const byte dirPin = 2;
const int stepsPerRev = 200; // Steps per revolution - may need to be adjusted
MoToStepper stepper1( stepsPerRev, STEPDIR ); // create a stepper instance
void setup() {
Serial.begin(9600);
stepper1.attach( stepPin, dirPin );
stepper1.setSpeed( 300 ); // 30 rev/min (if stepsPerRev is set correctly)
stepper1.setRampLen( stepsPerRev / 2); // Ramp length is 1/2 revolution
stepper1.rotate(1); // start turning, 1=vorward, -1=backwards
}
void loop() {
int pot = analogRead(A0);
int speed=map(pot, 0, 1023, 10,7500); // 1 ... 750 RPM
Serial.println(speed);
stepper1.setSpeed( speed );
delay(100);
}