HELP

I am having trouble running the millis code. How can I tell my code when to start the time and then when to reset the time??

People (sensibly) tend to ignore postings entitled “HELP”.

Did you read the instructions?

Post what you have done so far.

.

You can't reset millis() unless you reset the processor.

Do you understand how the Blink Without Delay example works?

The demo Several Things at a Time illustrates the use of millis() to manage timing.

EVERY Thread in this Forum is looking for help. You should use a title that summarises your problem so that people who can't help don't waste time reading your Post. Actually many Forum contributors just ignore Threads with uninformative titles.

...R

DVDdoug: You can't reset millis() unless you reset the processor.

Nope.

While it is not a good idea to reset millis, it can be done easily:

extern volatile unsigned long timer0_millis;

void setup() {
  Serial.begin(115200);
  Serial.println(F("Reset millis() all 5 seconds"));
}

void loop() {
  if (millis() > 5000) {
    Serial.print(F("millis() = "));
    Serial.println(millis());
    noInterrupts();
    timer0_millis = 0;
    interrupts();
    Serial.print(F("millis() = "));
    Serial.println(millis());
  }
}
Reset millis() all 5 seconds
millis() = 5001
millis() = 0
millis() = 5001
millis() = 0
millis() = 5001
millis() = 0
millis() = 5001
millis() = 0
millis() = 5001
millis() = 0
millis() = 5001
millis() = 0
millis() = 5001
millis() = 0
millis() = 5001
millis() = 0

AbeBrowne: I am having trouble running the millis code. How can I tell my code when to start the time and then when to reset the time??

Hi Abe, Are you still here? First off, post the code you are using so we know what you are talking about. "The millis code" is a little ambiguous. Use code tags, which you will learn about in the "instructions" linked above.

Then tell us what you are trying to achieve with your code. It often turns out that there is an easier way.

Robin2: Actually many Forum contributors just ignore Threads with uninformative titles.

But you just can't can you? :grinning: :grinning: