# Serial print commands for debugging

**URL:** <https://forum.arduino.cc/t/serial-print-commands-for-debugging/1075884>\
**Category:** Programming\
**Created:** [January 10, 2023, 10:17pm UTC](https://forum.arduino.cc/t/serial-print-commands-for-debugging/1075884 "2023-01-10T22:17:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SouthernAtHeart](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/southernatheart/32/698312_2.png) [@SouthernAtHeart](https://forum.arduino.cc/u/SouthernAtHeart)\
**Post date:** [January 10, 2023, 10:17pm UTC](https://forum.arduino.cc/t/serial-print-commands-for-debugging/1075884/1 "2023-01-10T22:17:37Z")

</div>

I put a few Serial.println() commands in my code in case I have issues and need to see some data from variables, etc. But in the normal operation of my projects, the Atmega chip isn't connected to a laptop so the serial port isn't used. Do these serial command still execute or slow down the operation of the code?

---

<div class="post-metadata">

**Author:** ![marco\_c](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@marco\_c](https://forum.arduino.cc/u/marco_c)\
**Post date:** [January 10, 2023, 10:19pm UTC](https://forum.arduino.cc/t/serial-print-commands-for-debugging/1075884/2 "2023-01-10T22:19:31Z")

</div>

Yes they do.

There are lots of ways to have 'debug' and 'not debug' code. Here's one: [https://arduinoplusplus.wordpress.com/2017/05/01/simple-debugging-for-arduino-sketches/](https://arduinoplusplus.wordpress.com/2017/05/01/simple-debugging-for-arduino-sketches/)

---

<div class="post-metadata">

**Author:** ![SouthernAtHeart](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/southernatheart/32/698312_2.png) [@SouthernAtHeart](https://forum.arduino.cc/u/SouthernAtHeart)\
**Post date:** [January 10, 2023, 10:26pm UTC](https://forum.arduino.cc/t/serial-print-commands-for-debugging/1075884/3 "2023-01-10T22:26:00Z")

</div>

That look like a very clean solution!

---

<div class="post-metadata">

**Author:** ![GrandPete](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grandpete/32/1126625_2.png) [@GrandPete](https://forum.arduino.cc/u/GrandPete)\
**Post date:** [January 10, 2023, 10:34pm UTC](https://forum.arduino.cc/t/serial-print-commands-for-debugging/1075884/4 "2023-01-10T22:34:04Z")

</div>

I used to define a "debug\_byte" the same way.  
But I used it differently like:

```cpp
#define DEBUG_byte 1
...
if (DEBUG_byte) {Serial.print("setup on-going");

```

so I need that code each time I need a print, anywhere in my sketch!  
so I will now use the hint you provide! 😀

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [July 9, 2023, 10:34pm UTC](https://forum.arduino.cc/t/serial-print-commands-for-debugging/1075884/5 "2023-07-09T22:34:11Z")

</div>

Closed on July 9, 2023, 10:34pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
