Search code examples
carduinoembeddedprocessingatmega

does arduino run the print function (print, println, printf, etc.) when no COM (Serial) port is connected or serial monitor open?


Im wondering the print statements in my code are taking up processing cycles when the robot isn't connected to the com port. I am running a time sensitive process and have reason to believe the execution of these lines could be slowing my bot down.


Solution

  • Yes It will take processing time even if no serial monitor or other device is connected.

    A good practice is to a have a #define pre-processor directive in your code indicating whether you are debugging or not.

    e.g.

    #define DEBUG_PHASE

    #ifdef DEBUG_PHASE
    printf(...);
    #endif