Stepper Motor Control via Serial

I’m really confused, basically what I’m trying to do is send a number (the number of steps the motor should take) through the serial port and have the motor do that. Whats odd is that when I use motorOne.setSpeed(9) it works great, but anything over 9 and the motor does a weird kind of blip and then stops. What I can’t wrap my head around it that when I use the example ‘stepper_oneRevolution’ sketch which i’ve tried to stay close to, the motor does what I want it to no problem with the setSpeed set at 60…
In the long run I want to send a long line through the serial port and have the arduino break it up into direction, speed, number or steps and then do it and wait for a new command.

Any help is greatly appreciated!
Thanks

#include <Stepper.h>

const int motorOneDrivePin = 8;
const int motorOneStepPin = 9;
int stepsToTake=0;
char ch;

int numberRecieved;


void setup() {
  
  Serial.begin(9600);
}

void loop()
{
  if ( Serial.available()) {
    ch=Serial.read();
    if (isDigit(ch))
    {
      numberRecieved=(numberRecieved*10)+(ch-'0');
    }
      else if (ch==10){
      stepsToTake=numberRecieved;
      numberRecieved=0;
      turn();
      }
    }  
}

void turn(){

const int stepsPerRevolution = 6400;
Stepper motorOne(stepsPerRevolution,8,9);
motorOne.setSpeed(8);///<-------- works at this speed would not work at motorOne.setSpeed(20);
  
Serial.println("steps to take:");
Serial.println(stepsToTake);
motorOne.step(stepsToTake);
delay(1000);
motorOne.step(-stepsToTake);
delay(1000);

}

Why are you defining a stepper instance inside a function? Do all the setup in setup(),
declare instances at top level:

Move these lines to top level from turn ()

const int stepsPerRevolution = 6400;
Stepper motorOne(stepsPerRevolution,8,9);

And move this line into setup():

  motorOne.setSpeed(8);///<-------- works at this speed would not work at motorOne.setSpeed(20);

Thanks for the tip! I’m currently away and didn’t pack my arduino but I’ll check to see if that helps when I get back in a month or so.
Merry Christmas!