I need this code to run every 1000 of a second while other stuff is happing

void TimePopDown() {
  Serial.println("TimePopDown RAN");
  for (int i = 0; i < moleNumber; i++) {
    if (popTime[i] != 0 ) {
      popTime[i] = popTime[i] - 1;
      Serial.print(popTime[i]);
      Serial.print(" ");

    };
    Serial.println("");
  };
}

so basically I have a array called popTime and it has a bunch of timer values that need to be decremented every millisecond. I then use that to turn a pin low later in some other code if it has not all ready be turn low by the user.

edit oh and i need a way to stop from run once all of the elements in the array equal zero.

if you want too see all my code, i well post it.

Read Robin2's discussion:

.

Just to verify your terminology...

1000th of a millisecond - is one microsecond.
I doubt that your function/code will complete within a single microsecond - so you'll get a crash pretty quickly.

HOWEVER, if you meant 1000mS, then that's entirely possible.
Set up a millis() timer, and every 1000mS - call your function.

yes every 1 millsecond

or every 1000 of a second sorry

Follow the BWD BlinkWithoutDelay design technique.

.