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);
Serial.begin(9600);
}
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;
else
ledState = LOW;
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
Serial.println(currentMillis);
}
}