You’ve recently learned about millis() and can’t way to delete all of your references to delay(). The problem is that you don’t know quite how to convert your code into millis()-compatible code. Here is a (running) list of millis() examples I’ve put together to help. Baldengineer’s Arduino millis() Examples Arduino Multitasking – Step by step examples of how to convert delay() code into millis() based code, to simulate multitasking. Police Lights – Flash two LEDs like…
The quick answer to “How do you reset millis()” is: You Don’t! And here’s why: if you did, it would potentially break most libraries and functions that rely on it. Generally the reason people want to reset it, is that they are concerned about rollover. Instead of focusing on resetting millis(), here is how to use it correctly.
Avoiding rollover and checking how much time as passed is done in a single line:
if ((unsigned long)(millis() - previousMillis) >= interval)
That single line of code is all that is really needed, to avoid rollover! Pretty simple, huh? So let’s go into more detail about how this works and what each of those variables does.