hi, don't have lot of experience arduino, make countdown timer can count down in years, days, , hours. have absolutely no idea begin , i'm more willing pay code or hardwiring. needs count down reliably 90 years. ideally done end of week.
i have arduino uno , startup kit comes it, , don't mind buying components think important.
many thanks! i'm in bit of hurry sooner can reply, better! <3 thank
i have arduino uno , startup kit comes it, , don't mind buying components think important.
many thanks! i'm in bit of hurry sooner can reply, better! <3 thank
what display countdown on?
how powered?
at point bound lose power - need battery backup thru that?
how long need run for? need account leap years , leap seconds if running long enough, or manually add them when occur.
time part simple enough, count 24 hours , count down day , year needed.
how powered?
at point bound lose power - need battery backup thru that?
how long need run for? need account leap years , leap seconds if running long enough, or manually add them when occur.
time part simple enough, count 24 hours , count down day , year needed.
code: [select]
unsigned long currentmicros;
unsigned long previousmicros;
unsigned long elapsedtime;
// initial time start, 10:00:00 90 years, 240 days. (around start of may),
// adjust needed.
// working, 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 been?
elapsedtime = currentmicros - previousmicros;
if ( elapsedtime >=10000ul){ // 0.01 second passed? update 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 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 1 second check
} // end loop
Arduino Forum > Community > Gigs and Collaborations > Please help me program a countdown timer?
arduino
Comments
Post a Comment