User Tools

Site Tools


en-us_commands:reference:debug

This is an old revision of the document!


Table of Contents

debug()

debug() outputs values only when debugging is enabled.

debug command operation flow

void debug(const __FlashStringHelper* value)
void debug(const String& value)
void debug(const char value[])
void debug(char value)
void debug(unsigned char value, int base = DEC)
void debug(int value, int base = DEC)
void debug(unsigned int value, int base = DEC)
void debug(long value, int base = DEC)
void debug(unsigned long value, int base = DEC)
void debug(double value, int digits = 2)

Commands

Command Arguments Return Value Operation
debug(value) const __FlashStringHelper* value void Outputs values only when debugging is enabled.

Example

const bool DEBUG_MODE = true;
 
void setup() {
  if (DEBUG_MODE) {
    debugStart(115200);  // Set the port and baud rate for debug output.
  }
}
 
void loop() {
  checkInput();
  checkOutput();
}
 
void checkInput() {
  debug("AI0=");  // Output values only when debugging is enabled.
  debugln(analogRead(A0));  // Read the raw analog value of the specified channel. / Output the debug value followed by a newline.
}
 
void checkOutput() {
  debug("millis=");  // Output values only when debugging is enabled.
  debugln(millis());  // Output the debug value followed by a newline.
}

Precautions

  • Do not use the same port for Debug and product communication.
  • Rapid repeated output can slow the control cycle and communication responses.
  • Stop unnecessary Debug output before deploying for operation.

← Built-in Command List

en-us_commands/reference/debug.1788791732.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki