My program is a bit large and I'm worried about stability.
I need to print data to both a file and to my lcdLCD. It's like this:
if (hour<10) {
dataFile.print("0");
}
dataFile.print(hour, DEC);
dataFile.print(":");
if (minute<10) {
dataFile.print("0");
}
dataFile.print(minute, DEC);
dataFile.print(":");
if (second<10) {
dataFile.print("0");
}
Then
if (hour<10) {
lcd.print("0");
}
lcd.print(hour, DEC);
lcd.print(":");
if (minute<10) {
lcd.print("0");
}
lcd.print(minute, DEC);
lcd.print(":");
if (second<10) {
lcd.print("0");
}
What is a smart way to make this shorter? Should I write a function to add the leading zero then another that does something like:
void printboth (thing) {
dataFile.print(thing);
lcd.print(thing);
}
good idea?