I write a code in Arduino that controlling a stepper motor useing accelstepper when resive a serial signal from visual basic that Contains acoordinate value the ardino will controlling the stepper motor by this value .the code is work very good but it run after 1 second after resive the value over the serial I want to run the code faster . her is the code
#include <AccelStepper.h>
#include <MultiStepper.h>
#include <AccelStepper.h>
#include <MultiStepper.h>
#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper stepper(1, 9, 8);
int pos = 0;
void setup()
{
Serial.begin(115200);
stepper.setMaxSpeed(90);
stepper.setAcceleration(90);
}
void loop()
{
if (Serial.available()){
int steps = Serial.parseInt();
stepper.moveTo(steps);
if (stepper.distanceToGo() == 0)
{
stepper.moveTo(stepper.currentPosition());
stepper.setSpeed(100);
}
}
stepper.run();
}