5774 shaares
#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(x) Serial.print (x)
#define DEBUG_PRINTDEC(x) Serial.print (x, DEC)
#define DEBUG_PRINTLN(x) Serial.println (x)
#else
#define DEBUG_PRINT(x)
#define DEBUG_PRINTDEC(x)
#define DEBUG_PRINTLN(x)
#endif
#ifdef DEBUG
Serial.begin(9600);
#endif
...
Then you can liberally scatter your code with "DEBUG_PRINT ("I think I'm here");",
all controlled by a simple "#define DEBUG"
Ako je macro definiran kao prazan npr. #define DEBUG_PRINT(x), a pozvan u kodu, samo bude izignoriran.
http://stackoverflow.com/questions/28931195/way-to-toggle-debugging-code-on-and-off
http://arduino.stackexchange.com/questions/9857/can-i-make-the-arduino-ignore-serial-print