Looking for a solution, I found an example of a program that displays text using a defined interval:
#define INTERVAL_MESSAGE1 10000
unsigned long time_1 = 0;
{
if (millis() >= time_1 + INTERVAL_MESSAGE1) {
time_1 += INTERVAL_MESSAGE1;
print_time(time_1);
Serial.print(flowMilliLitres);
Serial.print(",");
Serial.println(totalMilliLitres);
}
After subtle changes (indicating what is to be displayed and changing variables to make the code more understandable overall), I got a result that is satisfactory. I use the millis() function in the program, so I understand the operation of the above code.
Is this a good solution?