Accumulate run run-time

Hi All,

I have a pump that runs intermittently and need to perform some clean-up stuff after every hour of run-time.

[edit] Forgot t mention that the pump can be running anywhere from one-minute to several hours at a time.
[/edit]

I am not sure if I am over-thinking this but have spent a lot of time trying to make this work.
Is there a simple method to accumulate that pump run time, then do the clean-up?

const oneHour = 3600000;
uint32_t runTime = 0;
bool pumpOn = false;

void setPump(bool toWhat) {
  if (toWhat) {
    digitalwrite(pinPump,HIGH);
    pumpOn = true;
//so here is where I would set the millis in a normal timing loop.
    pumpRunTime = millis();
//but, they need to be accumulated -- not just started
  } else {
    digitalwrite(pinPump,LOW);
    pumpOn = false;
  }
}

void checkPumpTime() {
  if (millis() - runTime > oneHour) {
    // Do the other stuff
    runTime = millis();
  }
}

Thanks

Please provide complete code (you can eliminate all code not relevant to your problem but that part should be complete), so we know how the routine are planned to be called.

Your code don't calculate the run time of the pump and it doesn't accumulate at all.

Keep in mind that you probably want to store the runtime into EEPROM at some point, so the accumulated value isn't lost with each reset.

Also remember to plan your EEPROM use so you don't burn up the ~100K write cycles too quickly!