stopping main loop and printing results?

Is it possible to have a sketch running for x num of loops, stop and then print the results of a bunch of variables?

Something like:

int index=1;
int variable=10;

void loop() {
  if (index>10) {
    Serial.print(variable);
    break;
  }
  index=index+1;
}

Thanks

Yes, but if you don’t want it to do anything after that, then it should be put in setup() and loop() should contain nothing.

Arrch: Yes, but if you don't want it to do anything after that, then it should be put in setup() and loop() should contain nothing.

hmmmm, interesting. Good idea - thanks

Also, you probably want to reset index to zero when you print something, otherwise there's a long wait for the next set of results.