Accelstepper. not working

Hi everyone

I discover the library accelstepper and it seem to be a great librairy.

I use:
Arduino UNO R3
Microstep drive DM542

I want to use the librairy with a Step and Dir pin.

I use this code:

#include <AccelStepper.h>


AccelStepper Xaxis(1, 13, 6); // pin 13 = step, pin 6 = direction


void setup() {
  Xaxis.setMaxSpeed(20);

  Xaxis.setSpeed(4);

}

void loop() {  
   Xaxis.runSpeed();

}

So if I want to simulate, is it ok use the 13 output with led to see the result. With this code, the led sould flash 4 time per second?

is it good?

You have not told AccelStepper how many steps you want it to take. You need an instruction like

Xaxis.move(400);

Try putting that in setup() and see what happens.

I don't understand your question about the LED on Pin 13.

...R Stepper Motor Basics

Thanks for you reply

I tried this but it stil not working.

I fund information on this website: here

I modify my code to this

#include <AccelStepper.h>

AccelStepper Xaxis(1, 13, 6); // pin 3 = step, pin 6 = direction


void setup() {
  Xaxis.setMaxSpeed(4);  //  4 step per sec
  Xaxis.setAcceleration(2);  // 2 step per sec^2
  Xaxis.move(200);  // move of 200 step

}

void loop() {  
  
  Xaxis.run();
   
}

I use the output 13 because when the output is active we have a led is turn on in same time. So it’s just interesting to see if the signal work.

Thanks

Step pulses are very short duration, measured in microseconds, you won't see anything.

i don't see any reason why your code wouldn't work, as long as the stepper is wired to the pins the code says they are. how long do you leave it before saying it doesn't work? your acceleration and maxspeed are very very low, so they will take some time to do anything. have you tried experimenting with higher values?

Yes, it's working.

The duration of the step is to short to see the light and it can not be test with a led. So at the begining I had an error in my code. So thank for you help.