Reading App Slider Input

I have built a motorized camera slider controlled by an Android app via bluetooth.

Controlling the motor using buttons in the app work as expected, but I am limited to the speeds defined by those buttons.

I would like to add a slider to the app (created in MIT App Inventor) that could set the speed to the stepper motor from 0 to 5000. I am, however, unsuccessful in getting it to work and am looking for guidance.

Code is below, and thanks in advance.

#include <AccelStepper.h>

AccelStepper stepper(AccelStepper::FULL2WIRE, 8, 9);

// Define our input button pins (reverse direction)
#define  button1 3
#define  button2 2

int spd = 1000;    // The current speed in steps/second
int sign = 0;      // Either 1, 0 or -1
 
void setup()
{ 
  Serial.begin(9600);
  stepper.setMaxSpeed(5000);
  stepper.setSpeed(5000);
  
  // Set up the three button inputs, with pullups
  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
}

void loop()
{ 
  char c;
  if(Serial.available()) {
    c = Serial.read();
    if (c == 'f') {  // forward
      sign = 1;
    }
    if (c == 'r') {  // reverse
      sign = -1;
    }
    if (c == 's') {  // stop
      sign = 0;
    }
    if (c == '1') {  // super slow
      spd = 100;
    }
    if (c == '2') {  // slow
      spd = 1000;
    }
    if (c == '3') {  // medium
      spd = 2000;
    }
       if (c == '4') {  // fast
      spd = 3000;
    }  
       if (c == '5') {  // faster
      spd = 4000;
    }  
       if (c == '6') {  // superfast
      spd = 5000;
    }
  }

  // when the slider hits the button, it sends it back in the reverse direction
  if (digitalRead(button1) == 0) {
    sign = 1;
  }

  // when the slider hits the button, it sends it back in the reverse direction
  else if (digitalRead(button2) == 0) {   
    sign = -1;
  }

  stepper.setSpeed(sign * spd);
  stepper.runSpeed();
}

What, exactly, is sending the serial data to the Arduino? Your post talks about getting data from your phone, so I suspect that you have a bluetooth device.

Get that device off the hardware serial pins, so you can debug your code. Debugging my guessing is for fools.

Yes, it is an HC-05 bluetooth module.

I am not sure what you mean by "Get that device off the hardware serial pins, so you can debug your code."

I am not sure what you mean by "Get that device off the hardware serial pins, so you can debug your code."

How IS the bluetooth device connected to the Arduino? Is it not connected to the hardware serial pins? If it is (and I KNOW that it is), connect it to some other pins, and use SoftwareSerial, NeoSoftSerial or AltSoftSerial (depending on which pins you use) to read from/write to it, so you can use Serial to debug your program (by Serial.print()ing what you read from the bluetooth device to the serial port that the Serial Monitor app is listening to.