Slow down data print out in serial monitor

Hi, whatever sensor I use, I like to read the data in serial monitor, but most of the time the data just zips right by so fast, I ended up put a delay(1000) at the end of the loop to slow it down. Is there a better way to do this? Thanks

There are more elegant ways to do this and the time might come when you want to use them but, if all you want to do is what you are doing, i.e. just slow things down, a delay is fine. It is simple to do and takes the least programming resources. Note that it means the computer does nothing but you may want to do something else in the wait time, or be more precise about the timing.

That's one way, good for prototyping. Another way is use blink without delay:

void loop(){
currentMillis = millis(); // all time elements are data type unsigned long
if ((currentMillis - previousMillis) >= printInterval){ // enough time passed yet?
previousMillis = previousMillis + printInterval; // yes, so set time for the next print event
// capture & print data, or print latest data, etc.
}
// other code to do other stuff, like reading buttons, monitoring serial port, controlling motors, etc
} // end of loop

Depending on what you want/need to see you could turn off Autoscroll in the monitor or only print say, one in 10 of the readings, so that you can see trends but not every value.

Thanks all for the replies. As far as I need, I just want to read the data purely for debug purpose. In the really app, I would not need the delay function and I will comment out all the println functions. So seems the delay function is fine. I just ask because I just want to know I am not doing anything wrong. :slight_smile: