can not get steppers to speed up.

I have been playing around with some steppers and controlling them with buttons. an X+, X- , Y+, Y- button. i have got the code so i can jog around the 2 axis table but it is very slow. I am using .9 degree steppers, 400 steps per revolution. I have set the speed everywhere from 30 RPM to 10 000 RPM but the steppers never seem to move faster than 1 or 2 RPM.

Could some one look at my code and see if i am missing something?

#include <Stepper.h>

int button1 = 12;
int button2 = 13;
int button3 = 7;
int button4 = 2;
int buttonState1 = 0; 
int buttonState2 = 0; 
int buttonState3 = 0; 
int buttonState4 = 0; 

const int stepsPerRevolution = 400;  

Stepper myStepper(stepsPerRevolution, 8,9,10,11);            
Stepper myStepper2(stepsPerRevolution, 3,4,5,6);

int stepCount = 0;  

void setup() {

  myStepper.setSpeed(1000);
  myStepper2.setSpeed(1000);

  pinMode (button1, INPUT);
  pinMode (button2, INPUT);
  pinMode (button3, INPUT);
  pinMode (button4, INPUT);

  Serial.begin(9600);
}

void loop() {
  buttonState1 = digitalRead(button1);
  buttonState2 = digitalRead(button2);
  buttonState3 = digitalRead(button3);
  buttonState4 = digitalRead(button4);

  if (buttonState1 == HIGH) {

    Serial.println("X+");
    myStepper.step(1);

  }
  else {
    Serial.println("Nothing x+");
  }
  if (buttonState2 == HIGH) {

    Serial.println("X-");
    myStepper.step(-1);

  }

  else {
    Serial.println("Nothing x-");
  }

  if (buttonState3 == HIGH) {

    Serial.println("Y+");
    myStepper2.step(1);

  }

  else {
    Serial.println("Nothing y+");
  }

  if (buttonState4 == HIGH) {

    Serial.println("Y-");
    myStepper2.step(-1);

  }

  else {
    Serial.println("Nothing y-");
  }

  if (buttonState4 == HIGH && buttonState2 == HIGH) {

    Serial.println("Y- , X -");

    myStepper.step(-1), myStepper2.step(-1);


  }

 
  if (buttonState1 == HIGH && buttonState3 == HIGH) {

    Serial.println("Y+ , X+");
    myStepper2.step(1),  myStepper.step(1);

  }

}

(code tags added by moterator)

Does the speed improve if all the serial.prints are commented out, or the serial speed is set faster?

    myStepper2.step(1),  myStepper.step(1);

This is a novel use of the comma operator. Almost makes one think you don’t know what you are doing, though.

Thank you CrossRoads, commenting out the serial printing worked, it is running great now. Why would that cause a problem?

PaulS sorry that i am not a programmer, but thank you for the positive reinforcement!

Why would that cause a problem?

Because it takes time to print and you are only stepping the motors one step at a time. Therefore your stepping rate is determined by the delays in the program calling for that single step. The speed setting is only effective when you do more than one step at a time.

Nuff said.