Hi,
My main sketch loop() has a delay(1) but I have a CO2 sensor that can't be read no faster than every 5 seconds, it'll error out otherwise. I can't change my delay to 5000 because that would make the whole app unresponsive.
I do have an RTC hooked up and I was thinking along the lines of
void loop() {
getCO2();
delay(1);
}
double getCO2() {
if (RTC.second%5 == 0) {
//read CO2 sensor
return co2
}
}
But the problem is if you call getCO2() at the wrong time, you're out of luck. I'd want to to return something on every call.
Or if I just use a while loop somehow without freezing up the app for 5 seconds?
thanks.