i will be designing a robot with multiple stepper motor. is it advisable to use millis instead of delay here or not? right now im testing if Millis() would work but still having a hard time programming this.

  • 2
    Depends on what you need to do. delay is a blocking call, while if you use millis you can do other things between checks for time. This may not be important if you are using a multi-core arduino or it may mean the difference between responsiveness and sluggishness. – Ron Beyer Jul 3 '19 at 3:35
  • This is a poor way to control stepper that requires acceleration, velocity limits and deacceleration to target position. Get a CNC shield and FET driver bridge and do it right with GRBL Panel,software to Uno uC interface on USB – Tony Stewart Sunnyskyguy EE75 Jul 3 '19 at 6:09
  • I use 10us step pulses using Arduino + CNC Shield + GRBL PANEL s/w over Windows via USB and get excellent servo speeds, home button (auto-cal) Jog buttons with tuned g,v, max constants and optimum step rates. Bit banging is so archaic. – Tony Stewart Sunnyskyguy EE75 Jul 3 '19 at 18:58

Arduino function delay() which pauses the program for an amount of milliseconds specified as parameter.

millis(), on the other hand, is a function that returns the amount of milliseconds that have passed since program start.

Just like delay() has a microsecond-version called delayMicroseconds(), millis() has micros(). If you need better resolution, micros() may be the way to go.

However, be aware that micros() will overflow after approximately 70 minutes, compared to millis()‘s 50 days. This means that the functions’ return values will start all over from zero.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.