1

I have an Arduino connected to a stepper motor with an Easy Driver. I want for the stepper motor turn to a coordinate point. I wrote a simple program in Visual Studio that sends a coordinate point to the Arduino. I tried to write this below to plot the coordinate point, but when I send a number to the Arduino, the stepper motor will only turn one step. I don't know how fix this.

Can anyone fix this problem please?

#include <AccelStepper.h>

AccelStepper stepper(1, 9, 8);

void setup()
{  
  Serial.begin(9600);
  stepper.setMaxSpeed(10000);
  stepper.setAcceleration(5000);
}

void loop()  
{  
  char c;

  if(Serial.available())      
  {      
    int steps = Serial.read();    
    stepper.moveTo(steps);   
  }   
  stepper.run();   
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.