Hi,
I am developing a code for Arduino in which I am using "#define DEBUG" statement.
If DEBUG is defined, I need to print debug log (which I have included as Serial.print() statement.) and if DEBUG is not defined I don't need to print the data present in Serial.print() statement. I am not able to recognize how to use conditional "#define DEBUG" in my code.
One way is to use input from serial terminal, Meaning if I'll give input from serial terminal as "DEBUG", "#define DEBUG" should be included in code and if I'll send "RESET" from serial terminal, it should not include "#define DEBUG" and code will not print any data on serial terminal.
Please guide to implement such scenario.
right now I am manually commenting #define DEBUG from the code when I don't need to print data on serial terminal, need to automate it based on inputs received from serial terminal.
Below is the code:
#define DEBUG
void setup()
{
Serial.begin(115200);
delay(1000);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
#ifdef DEBUG
Serial.print("Hello World!!!");
#endif
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
Thanks & Regards, Shruti