Should I use Millis or stick with Delay for my project?

I am making a four legged walker with 12 micro servos and some 3D printed parts.

Its really just going to walk and move, I dont plan on adding sensors but maybe in the

future.

I have been playing around with a sketch and am able to move the legs around and slow

them down and such. The more I read about the arduino programming language, the more

it looks like I should be using Millis instead of delay but that looks like a whole different and

much more complicated way of moving servos and I have not found how to move them

opposite of each other or how to slow or speed them up using Millis.

Should I stick with Delay for now or go ahead with Millis.

Thanks.

Absolutely, the sooner the better.

millis() isn’t limited to freeing up sensors, but can allow dynamic changes in gait, several concurrent moves can occur at the same time (needed for balance etc)

It is not that difficult but it requires a different way of thinking.
And as a consequence restructuring of your current program.
Have a look at blink without delay and state machine examples. See if you can understand those and build from there.
Don't be afraid. Try.

I would be inclined to use millis() from the start if you can. As your program gets more complicated it will get harder to change.

It's not that difficult, and once you understand the basic technique it makes your code much more flexible.

Check out the classic example sketch BlinkWithoutDelay.

There are also lots of tutorials that attempt to explain the basic principle... like this one.

https://www.gammon.com.au/blink

If you post your code we may be able to provide advice on ways that you could change it.

1 Like

Thank you for the replies. This morning I started playing around with millis.

This Blink without delay example makes non-blocking timing harder to understand than it must be.

The reasons are:

  1. no everyday analogon at all
  2. not enough commenting
  3. no "encapsulation" of the function but instead spreading the used variables

This tutorial uses an everyday example of baking a frosted pizza to explain the basic principle

especially for servos there are multiple libraries that make it easy to slow down servo-movements.

best regards Stefan

Also check out @Koepels " Fun With Millis"

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.