Please help me program a countdown timer?

hi, so i don't have a lot of experience with arduino, but i would like to make a countdown timer that can count down in years, days, and hours. i have absolutely no idea where to begin and i'm more than willing to pay someone to help with the code or the hardwiring. it needs to count down reliably from about 90 years. i would ideally like to get everything done by the end of the week.

i have an arduino uno and the startup kit that comes with it, and i don't mind buying any components you think would be important.

many thanks! i'm in a bit of a hurry so the sooner you can reply, the better! <3 thank you :slight_smile:

What will it display the countdown on?
How is it powered?
At some point you are bound to lose power - will it need battery backup to get thru that?
How long does it really need to run for? Need to account for leap years and leap seconds if it will be running long enough, or manually add them when they occur.

Time part itself is simple enough, count up 24 hours like this and count down a day and year as needed.

unsigned long currentMicros;
unsigned long previousMicros;
unsigned long elapsedTime;

// Initial time to start, 10:00:00 with 90 years, 240 days. (around start of May),
// adjust as needed.

// Get this working, then more display code if needed

byte hundredths;
byte tenths;
byte secondsOnes = 0;
byte oldsecondsOnes;
byte secondsTens = 0;
byte minutesOnes = 0;
byte minutesTens = 0;
byte hoursOnes= 0;
byte hoursTens = 1;
int days = 240; //
byte years = 90;

void setup(){

Serial.begin(115200); // make serial monitor match
Serial.println (Setup Done");
}

void loop(){

currentMicros = micros();

// how long's it been?
elapsedTime = currentMicros - previousMicros;
if ( elapsedTime >=10000UL){  // 0.01 second passed? Update the timers
previousMicros  = previousMicros + 10000UL;
hundredths = hundredths+1;
if (hundredths == 10){
    hundredths = 0;
    tenths = tenths +1;
    if (tenths == 10){
        tenths = 0;
        secondsOnes = secondsOnes + 1;
        if (secondsOnes == 10){
            secondsOnes = 0;
            secondsTens = secondsTens +1;
            if (secondsTens == 6){ 
                secondsTens = 0;
                minutesOnes =  minutesOnes + 1;
                if (minutesOnes == 10){
                    minutesOnes = 0;
                    minutesTens = minutesTens +1;
                    if (minutesTens == 6){
                        minutesTens = 0;
                        hoursOnes = hoursOns + 1;
                          if (hoursOnes == 10){
                              hoursOnes = 0;
                              hoursTens = hoursTens +1;
                                if ( (hoursTens == 2) && (hoursOnes == 4){
                                      hoursOnes = 0;
                                      hoursTens = 0;
                                      if (days>1){
                                          days = days-1;
                                           }
                                      else {
                                         days = 365;
                                         years = years - 1;
                                         }                             
                                      } // 24 hr rollover check
                                   } //hoursTens rollover check
                              } // hoursOnes rollover check
                        } // minutesTens rollover check
                     } // minutesOnes rollover check
                 } // secondsTens rollover check
              } // secondsOnes rollover check
          } // tenths rollover check
       } // hundredths rollover check
} // hundredths passing check

if (oldSecondsOnes != secondsOnes){  // show the elapsed time
oldSecondsOnes = secondsOnes;
Serial.print (years);
Serial.print(":");
Serial.print(days);
Serial.print(":");
Serial.print(hoursTens);
Serial.print(hoursOnes);
Serial.print(":");
Serial.print(minutesTens);
Serial.print(minutesOnes);
Serial.print(":");
Serial.print(secondsTens);
Serial.println(secondsOnes);

} // end one second check

} // end loop

I will need the counter to display on my LCM1602C, and would also very much appreciate hardwiring instructions for how to set up my arduino uno alongside the code. would this be possible?
I can run it off of a battery for now; it only is going to be used for display purposes and won't actually be running for 80-odd years.

will i just be able to copy and paste that code in?

Hello,

First of all, the Oscillator of the arduino isn't perfect. If you will only use it for demonstration purposes for a short amount of time this won't be a problem. I think the best choice would be to use timer interrupts and subtract something from the years, the days, the hours... , and convert these numbers to a string what you into the lcd library. If you use it in this setup no additional components will be required.

Jasper

Hello,

The wiring will be exactly the same as described in many tutorials. you won't be able to copy and paste the code of CrossRoads for it to function in one time. Instead of Serial.print(...), Serial.print(...), you will have to say something like finalDate = strinf(years)+':'+string(days)':'+ and so on.

Jasper

Hi Chesh,

I just programmed a nice countdown timer for a client and I can tell you that the internal oscillator on the Uno is off by ~5 seconds/hour, so you'll need an RTC module. I have programmed these before too, so if you're still interested in having someone help, I can hammer it out in 1-2 days depending on what you need.

If you send me the parts, I can mail you back a finished project (wired, tested, programmed, commented code).

Check out my linked-in profile for insight and ideas: https://www.linkedin.com/in/stanislavzivanov

Stan