Stepper motor speed control via blutooth

Hey chaps! I am currently working on a project. My aim is to controll a stepper motor via android blutooth. I am using the uno. The setup works well. I am able to start and stop the stepper via buttons on blutooth console on my phone by issuing commands suchave as f1,f2,f3…but what I would like to achieve is a slow gradual speed from min to max. Could someone please help with this code to implement this.

#include <AccelStepper.h> // Library created by Mike McCauley at http://www.airspayce.com/mikem/arduino/AccelStepper/
// AccelStepper Setup
AccelStepper stepper(1, 5, 6); // 1 = Easy Driver interface, Pin 4 connected to STEP pin of Easy Driver, Pin 5 connected to DIR pin of Easy Driver

#include <SoftwareSerial.h>
SoftwareSerial portOne(0, 1); // software serial #1: TX = digital pin 10, RX = digital pin 11


// Define our three input button pins
#define button1 3
#define button2 2

int spd = 8000; // The current speed in steps/second
int sign = 0; // Either 1, 0 or -1

void setup()
{ 
Serial.begin(9600);
stepper.setMaxSpeed(10000);
stepper.setSpeed(1000);

// 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 = 10;
}
if (c == '2') { // slow
spd = 100;
}
if (c == '3') { // medium
spd = 300;
}
if (c == '4') { // fast
spd = 500;
} 
if (c == '5') { // faster
spd = 8000;
} 
if (c == '6') { // superfast
spd = 10000;
}
}
if (digitalRead(button1) == 0) {
sign = 1;
}
else if (digitalRead(button2) == 0) { 
sign = -1;
}
stepper.setSpeed(sign * spd);
stepper.runSpeed();
}

As you might guess from its name the AccelStepper library is designed for acceleration.

You are using the command runSpeed() which does not use acceleration. Use the command run()

And I don't see any moveTo() command in your program - so how does the library know how far to move the motor?

...R

The stepper will run continuously untill a stop command is issued. I basically need to know how to add a command for 0-100% speed that can be controlled via a slider on android. The current code works fine for the defined speeds.

sternfox:
The stepper will run continuously

The AccelStepper library is not designed for that, and it is not the way stepper motors are normally used. Do you really need a stepper motor?

It would not be difficult to write your own code for that motor without using any library. Have a look at this Simple Stepper Code - especially the second example. For what you want you should probably check for a new command between every step.

I also posted a simple program using acceleration here

...R
Stepper Motor Basics

Yes need the stepper motor for the torque. I'm running a nema34 @8nm @60volts through a industrial cnc driver. I have seen a few projects that have variable speed control via bluetooth but no code examples available. I think I will add more speed increases to the code I posted and call each speed with the slider.