Slider issue values

Hi everyone, I'm creating an app to vary the speed of a stepper motor using a cnc shield with arduino but the problem is that with lower values than 60 rpm the motor does not run, also I would like to ask if is it possible to have more precise values with the slider for example it goes to 98 rpm to 102 and I need 100.

#include <SoftwareSerial.h>
#include <AccelStepper.h>

// Definimos los pines utilizados
const int pinStep = 4;
const int pinDir = 7;
const int pinEnable = 8;
// Creamos un objeto de tipo AccelStepper
AccelStepper stepper = AccelStepper(1, pinStep, pinDir);
SoftwareSerial BTSerial(10, 11); // Creamos un objeto SoftwareSerial para la comunicación Bluetooth
void setup() {
  // Configuramos los pines
  pinMode(pinEnable, OUTPUT);
  digitalWrite(pinEnable, LOW); // Habilitamos el driver
  
  // Configuramos el objeto AccelStepper
  stepper.setMaxSpeed(2000); // Velocidad máxima en RPM
  BTSerial.begin(38400); // Iniciamos la comunicación Bluetooth
  void loop() {
  // Definimos la velocidad en RPM y la dirección
 while (BTSerial.available() > 0) {
    int rpm = BTSerial.parseInt(); // Leemos el valor de RPM enviado desde la app
    const int dir = -1; // 1 para CW, -1 para CCW
  // Definimos la velocidad en RPM y la dirección
  if (BTSerial.read() == ',') { // Si se recibió información por Bluetooth
    
    rpm = constrain(rpm, 0, 600);
    // Configuramos la velocidad y la dirección del motor
    stepper.setSpeed((dir * rpm / 60) * 200); // Convertimos RPM a pasos por segundo
       
  }
  }
}

image



the range of the slider is 0 to 600
I appreciate any idea

Dear @Juan_Berrio , welcome to the Community.
As far as the resolution of the slider is concerned you can try to enlarge the slider's "x" dimension at the complete width of your phone (or pad) and set as its maximum value to the max number of pulses per second and do the computation into the app instead of making it into your Arduino code.
Another hint is to set the 0 value of the slider at the center of your phone, so for negative numbers you have the ccw rotation (it is already done like that ? it is not clear in the Arduino code).
But, to have the best resolution, you can adopt a different approach (like @TIMAI2 has posted a couple of days ago in another similar post) : that is to have increasing and decreasing buttons. In such a way you'll have whatever resolution you need.
image
Best wishes.

You could also use a thin Canvas as a slider.

I'll give it a try to your advices, I'll be telling you

Hi everyone, could you tell me how to vary the slider to get every number from 0 to 600?, I already have the slider covering all the screen but it jumps for example if I need a 200 I get a 198 or a 204
Thank you

the slider uses currencty only 100 steps between min and max value, see also this feature request

Taifun