how to use accel stepper

A few things ...

Edit your post and enclose your code in code tags (as explained in the How to Use The Forum) so it looks like this

Second, your code is long and poorly organized so I can't quickly see what it is supposed to do. It would be much easier to follow if you put the different actions into separate functions so that each piece is short.

Third, those delay() commands are likely to screw things up because the Arduino can do nothing else while it works through the delay period. Study the technique in the Blink Without Delay example in the IDE and look at the example I wrote in the first post of this Thread.

...R