Millis() not working

It's ok, because these 'zeros' are only outputted once. And because there is no delay from start, not even 1 millisecond has elapsed when millis() is called the first time.

The main reason, that your code doesn't work, is the incorrect usage of .distanceToGo(). As already stated, you must check for 0, and not for 3520.

What happens with your code is:

  • when stepper17.runSpeedToPosition();is called for the first time after setup, no step is generated, because millis is still 0.
  • because no step is generated, the distanceToGo() is still 3250, and the while loop is exited immediately.
  • Your serial prints are printed with all values of 0
  • loop() is started again. Now millis() is > 0 and a step is generated with the first call of runSpeedToPosition(). Now distanceToGo is < 3250, and your while loop will never end. So no further printing.
  • Because the while loop calls runSpeedToPosition() again and again, your stepper does its 3520 steps, but the while loop will not end after that - it loops endless.

You can prevent the special behaviour of Accelstepper in the first call of loop ( with millis() == 0 ) if you add a short delay at the end of setup ( a delay(1) is sufficent ). Now your while will loop endless from the beginning, and you will never get an output to the serial monitor.

Hope this helps understanding what is happening.