// include Arduino stepper motor library #include // change this to the number of steps on your motor #define STEPS 32 // create an instance of the stepper class, specifying // the number of steps of the motor and the pins it's // attached to Stepper stepper(STEPS, 8, 10, 9, 11); void setup() { Serial.begin(9600); while (! Serial); Serial.println("Enter a speed from 2 to 500"); } int direction_ = 1, speed_ = 400, val=0; void loop() { if (Serial.available()) { val = Serial.parseInt(); Serial.print("VAL = "); Serial.println(val); if (val > 1 && val <= 500) { speed_=val; Serial.print("SPEED = "); Serial.println(speed_); } } stepper.setSpeed(speed_); // move the stepper motor stepper.step(direction_); }