Help with Using accelStepper to run multiple steppers with user input

Hello, I need some help with this code. I am trying to use accelStepper to run multiple steppers at the same time and uses the serial monitor to determine the steps for each stepper. I also have a problem with imputing a large value of steps like the number 1000000. The code is below and I have added another block of code that works, but does not have the user input that I’m trying to do for the steps.Thank you.

accelStepper URL accelStepper

#include <MultiStepper.h>
#include <AccelStepper.h>

//Stepper pins
AccelStepper stepperX(AccelStepper::DRIVER, 3, 5);
AccelStepper stepperZ(AccelStepper::DRIVER, 6, 9);

String in;
int myNumber = 0;
int val;
int motor1_steps = 0;
int motor2_steps = 0;
char c;
String Command;

void setup()
void loop(){

 //if (stepperX.isRunning()== false && stepperZ.isRunning()== false){
 Serial.println("Imput# xSteps");
 Serial.println("Imput# zSteps");
//if (stepperX.isRunning()== true && stepperZ.isRunning()== true){
//  Command = Serial.readString();
//  if(Command = "stop" || "STOP" || "Stop");
//    stepperX.stop();
//    stepperZ.stop();
void RunStepper(){;;


#include <MultiStepper.h>
#include <AccelStepper.h>
//Stepper pins
AccelStepper stepper1(AccelStepper::DRIVER, 3, 5);
AccelStepper stepper2(AccelStepper::DRIVER, 6, 9);

void setup()
void loop()
   // Change direction at the limits
   if (stepper1.distanceToGo() == 0)

Stepper_XZaxis.ino (1.37 KB)

Stepper_Simple_XZaxis.ino (580 Bytes)

I also have a problem with imputing a large value of steps like the number 1000000.

You can't store that big a number in a sixteen bit int.

Please remember to use code tags when posting code

To make it easy for people to help you please modify your post and use the code button </>

so your code looks like this

and is easy to copy to a text editor. See How to use the Forum

Your code is too long for me to study quickly without copying to a text editor.

The MultiStepper library does not use acceleration, but, from what I can see your code does not use that library. The purpose of the MultiStepper library is to enable a number of motors to be controlled in a coordinated way - for example MotorA does 137 steps in the same time that MotorB does 293 steps. If you don’t need that coordinated control then just use the regular AccelStepper library.

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. This can happen after the program has been running perfectly for some time. Just use cstrings - char arrays terminated with ‘\0’ (NULL).

Don’t use Serial.readString() as it blocks the Arduino and may interfere with the stepping of your motors.

Have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

Rather than send “Stop” just send ‘S’. Single character commands will make the Arduino program much simpler.

Stepper Motor Basics
Simple Stepper Code