#define DEBUG
// a bunch of code...
void setup() {
#ifdef DEBUG
Serial.begin(9600);
#endif
// more code...
}
void loop()
{
int val;
// some code...
#ifdef DEBUG
Serial.print("val = ");
Serial.println(val);
#endif
// more code..
If you have the #define for DEBUG active, the Serial object is compiled into the code. If you comment out that line, all #ifdef's become false and the Serial object is not compiled into the code. This makes it easy to leave debug code in the file, but only activate it when needed.