How do i reset Millis to 0?

Hi i did a little searching and all i could find is:

timer0_overflow_count = 0;

This does not work in my code i get errors. I need my code to run for 90days min and i have read millies will overflow after 49 days> this will crash my code. My code is below and the millisecond have been lowered in this code for testing purposes but they usualy keep the LED on for 12 hours and then off for 12 Hours. If someone could show me how to edit this code to reset the millies after it goes above “maxMillis” variable i would be very grateful.

// constants won't change. Used here to 
// set pin numbers:
const int ledPin =  13;      // the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated
long maxMillis = 4000;             // Will store the max amount of millies bofore previousMillis and currentMillis is reset to zero

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 1000;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);      

void loop()

  unsigned long currentMillis = millis();
 if (currentMillis > maxMillis) {
   previousMillis = 0;
   timer0_overflow_count = 0
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);

This question comes up regularly (like clockwork, you might say), and the answer is always another question - "why?"

this will crash my code

So, improve your code.

Here's a hint: What datatype does "millis()" return?

Interger? :~ :~ :~ :~ :~ :~ :~

Yes, unsigned long is an integer datatype

You don't reset millis(), instead, use it properly.

yer i did stumble upon that while i was searching but did not full understand it so i could not see how to implement it into my code :(

Your existing code will already deal with it for you. This is fine and will handle rollover:

  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;

Just get rid of this:

 if (currentMillis > maxMillis) {
   previousMillis = 0;
   timer0_overflow_count = 0


check my stopWatch class, - - millis() based counter that can be reset to 0 anytime...

FYI a 1.0 compatible version is in the pipeline, see discussion thread -,64024.0.html -