Ah string, yes, I got all jumbled up. I tried unsuccessfully working with strings last week.
As for the entire code, the whole thing will be too long to post the entire thing in one post, but the displayDate() function is:
//setting up seconds time conversion
#define secondsinaday 86400 //((60*60)*24)
#define secondsinhour 3600 //(60*60)
#define secondsinminute 60
long countpreviousMillis = 0; //stores count milliseconds
long countinterval = 1000; //1 second
void displayDate(){
unsigned long countcurrentMillis = millis();
if(countcurrentMillis - countpreviousMillis > countinterval) {
// save the last time counted
countpreviousMillis = countcurrentMillis;
totalsectime--; //decrement of 1 second
unsigned long sectime = totalsectime;
/*takes the totalsectime variable and converts it inside of this function
so that the time conversions do not interfere with the later functions */
unsigned long days = sectime/secondsinaday; //calculates seconds in a day
sectime = sectime % secondsinaday; //takes the remainder of the previous calculation
unsigned long hours = sectime/secondsinhour; //calculates seconds in an hour
sectime = sectime % secondsinhour; //takes the remainder of the previous calculation
unsigned long minutes = sectime/secondsinminute; //calculates seconds in a minute
unsigned long seconds = sectime % secondsinminute; //takes the remainder, and that is seconds
/*below takes the values generated from above and makes variables for each digit to display
based on on dividing the values by hundreds/tens/single numbers*/
unsigned long days_hundreds = days/100;
unsigned long days_tens = (days %100)/10;
unsigned long days_units = (days %100)%10;
unsigned long hours_tens = (hours %100)/10;
unsigned long hours_units = (hours %100)%10;
unsigned long minutes_tens = (minutes %100)/10;
unsigned long minutes_units = (minutes %100)%10;
unsigned long seconds_tens = (seconds %100)/10;
unsigned long seconds_units = (seconds %100)%10;
//sends digit to: 7221 device
//digit order
//variable from above calculations
//true/false for the decimal point
lc.setDigit(1,0,days_hundreds,false);
lc.setDigit(1,1,days_tens,false);
lc.setDigit(1,2,days_units,false);
lc.setDigit(0,0,hours_tens,false);
lc.setDigit(0,1,hours_units,false);
lc.setDigit(0,2,minutes_tens,false);
lc.setDigit(0,3,minutes_units,false);
lc.setDigit(0,4,seconds_tens,false);
lc.setDigit(0,5,seconds_units,false);
}
if(totalsectime==15){ //wrap-around when time reaches 15 seconds
displayWrap();
return;
}
if(totalsectime<=15){ //wrap-around when time reaches 15 seconds
lc.shutdown(0,false);
lc.shutdown(1,false);
}
if(totalsectime <=5 ) { //lights emitter LEDs when time reaches 5 seconds and keeps speaker solid
digitalWrite(emitters, HIGH);
}
else{
digitalWrite(emitters, LOW);
}
if(totalsectime > 20){
updatespeaker();
}
if(totalsectime > 5){ //colon blink function for normal countdown
colonBlink();
}
if(totalsectime < 21){
twentyspeaker();
}
if(totalsectime < 10){
tenspeaker();
}
if(totalsectime <= 0){
zerospeaker();
delay(2500);
displayFade();
genserOne();
displayWrap();
delay(5000);
displayWrap();
totalsectime = random(16756131);
}
}
I'm sure the code is bloated and inefficient, but it does operate currently, and I will work on making the code more efficient and memory conservative as I work on it. Still working on the learning curve.
I'm also using the LedControl Library for the 72xx display drivers to drive seven segment displays.
I didn't have any code previously to the suggestions, as I wasn't sure how to achieve what I wanted other than just regular intervals of on/off using millis().