can I use millis() and delay() in the same code?
Welcome to the forum
You can use them in the same sketch but it is usually not a good idea because delay() halts the program for the period that you specify.
As a result, if your sketch depends on testing the value of millis() frequently then any delay() of more than one millisecond will cause a problem
Of course you can. But as @UKHeliBob mentions... delay blocks all other code from running so you need to be aware of this... as it may impact your coding logic.
You can pretty much do everything with millis()... have a look at some of the examples... just search Blink Without Delay.
Yes. Post the code you are working on that uses delay() and millis().
As you may have figured out by now, sometimes they get along, so to speak, and sometimes they don't.
a7
Yes, you may use millis() and delay() in the same code but you will encounter issues.
you "might" encounter issues. depends what OP does.
I thought about using the word "might" but decided against it. I'm sure the OP will do the does to cause a millis()/delay() issue. My Spidey sense is all atingle.
![]()
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.