Skip to content

Instantly share code, notes, and snippets.

@Mayoogh
Created August 2, 2024 09:42
Show Gist options
  • Save Mayoogh/aab5be71478fce29d58a6e1c8a2f6f4f to your computer and use it in GitHub Desktop.
Save Mayoogh/aab5be71478fce29d58a6e1c8a2f6f4f to your computer and use it in GitHub Desktop.
Debug Serial
#define DEBUG 1 // Set to 0 to disable debugging, 1 to enable
#if DEBUG
#define DEBUG_PRINT(x) Serial.print(x)
#define DEBUG_PRINTLN(x) Serial.println(x)
#else
#define DEBUG_PRINT(x)
#define DEBUG_PRINTLN(x)
#endif
void setup() {
Serial.begin(9600);
// Actual operation serial prints
Serial.println("Starting the system...");
// Debugging serial prints
DEBUG_PRINTLN("Debug: Entering setup");
// Other setup code
}
void loop() {
// Actual operation serial prints
Serial.println("System running...");
// Debugging serial prints
DEBUG_PRINTLN("Debug: Inside loop");
// Other loop code
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment