I'm using NodeMcu along with pulse sensor to monitor the values.
Currently I'm using this simple code
Serialprint(analogRead(A0));
delay(5000);
This code monitors and provides the values after giving a delay of 5 seconds after each value.
I want the modify the code in such a way that the NodeMcu will continuously monitor for 10 mins without any delay. After 10 mins, a delay of 5 seconds will occur. Again the NodeMcu will monitor for 10 mins and this way it will continue. I can't find a way to do that. Is there any way to do this ??
//https://forum.arduino.cc/t/delay-after-a-fixed-time/884660
// download SafeString V4.1.5+ library from the Arduino Library manager or from
// https://www.forward.com.au/pfod/ArduinoProgramming/SafeString/index.html
// for the millisDelay class
#include "millisDelay.h"
millisDelay tenMinTimer;
const unsigned long TEN_MIN_MS = 10ul * 60 * 1000; // not the ul
millisDelay fiveSecDelay;
const unsigned long FIVE_SEC_MS = 5ul * 1000;
void setup() {
Serial.begin(115200); //for debug
for (int i = 10; i > 0; i--) {
delay(500);
Serial.print(i); Serial.print(' ');
}
Serial.println("started");
tenMinTimer.start(TEN_MIN_MS);
}
void loop() {
if (tenMinTimer.isRunning()) { // only while timer is running
Serial.println(analogRead(A0));
}
if (tenMinTimer.justFinished()) { // after 10mins
fiveSecDelay.start(FIVE_SEC_MS);
}
if (fiveSecDelay.justFinished()) {
tenMinTimer.restart(); // start reading again
}
}