will be read-only starting December 31st, 2018. For more info please look at this Forum Post

SerialDebugger Library for Arduino
Author:  Alexander Brevig


Current version

1.2 2009-04-15: No longer needed to modify Arduino core.


1.2 2009-04-15: No longer needed to modify Arduino core.
1.2 2009-04-15: Tested And Functional
1.2 2009-04-13: Beta
1.1 2009-04-12: Beta
1.0 2009-04-12: Beta


SerialDebugger is a library for the Arduino.

It is created to help debugging using serial output.

This class uses the CascadablePrint Library.

Download, install and import

Download here:

Put the SerialDebugger folder in "hardware\libraries\".

In the Arduino IDE, create a new sketch (or open one) and

select from the menubar "Sketch->Import Library->SerialDebugger".

Once the library is imported, an '#include <SerialDebugger.h>' line will appear

at the top of your Sketch.



The SerialDebugger is an instance of the SerialDebug library. So it is already created.

You only need to worry about configuring it to suit your needs.

Custom SerialDebugger

Available Constructors

  • SerialDebug()
  • SerialDebug(unsigned int baudrate)
  • SerialDebug(unsigned int baudrate,uint8_t state)
  • SerialDebug(uint8_t uart,unsigned int baudrate,uint8_t state)

//this initializes a SerialDebug object named debugger connected to the Arduino Serial object. SerialDebug debugger = SerialDebug(9600);


  • Debug types
    • ERROR


void begin(unsigned int baudrate)

Wrapper for Serial.begin. Calling this will add 332 bytes to your sketch binary.

  • Parameter baudrate is passed on to Serial.begin

void begin(uint8_t uart, unsigned int baudrate)

Wrapper for Arduino Mega multiple Serial objects.

  • Parameter uart should be 1,2,3 or 4.
  • Parameter baudrate is passed on to Serial/Serial1/Serial2/Serial3.begin

void enable(uint8_t state)

void disable(uint8_t state)

void toggle(uint8_t state)

bool debug(uint8_t type, char* source, char* message)

  • Parameter type is one of the debug states.
  • Parameter source should describe wher the debug happened
  • Parameter message should contain the message that is to be debugged/delivered to serial.

Inherited from Print

  • void print()
  • void println()


  1. /*
  2. ||
  3. || @author Alexander Brevig
  4. || @version 1.0
  5. ||
  6. || @description
  7. || Demonstrates the functionality of the SerialDebugger
  8. ||
  9. */
  11. #include <SerialDebug.h>
  13. #define DEBUG true
  15. void setup(){
  16.   if (DEBUG){
  17.     //SerialDebugger.begin(2,9600); //can select uart
  18.     SerialDebugger.begin(9600); //if this line is commented out, the binary sketch size will decrease by 332 bytes
  19.   }
  20.   SerialDebugger.enable(NOTIFICATION);
  21.   //SerialDebugger.enable(ERROR);//uncomment if you want to debug ERRORs
  22. }
  24. void loop(){
  25.   SerialDebugger.debug(NOTIFICATION,"loop","notifications are enabled");
  26.   if (SerialDebugger.debug(ERROR,"loop","errors are disabled")){
  27.     //do actions that might be required when debugging errors
  28.     //(re)setting variables
  29.     //additional SerialDebugger.debug() calls
  30.   }
  31.   delay(1000);
  32. }


How can I use multiple SerialDebuggeres?

SerialDebugger is not a class. Therefore to add an additional SerialDebugger you will need to create a new object.

One could add a SerialDebugger called mySerialDebugger with uart 3, baudrate=9600 , and a default accept for ERRORs for Arduino Mega with the following line:

SerialDebugg mySerialDebugger = SerialDebug(3,9600,ERROR);

  SerialDebugger.debug(NOTIFICATION,"example","SerialDebugger says hello!");
  mySerialDebugger.debug(ERROR,"example","mySerialDebugger says hello!");

Information about this page

Part of AlphaBeta Libraries.
Last Modified: May 09, 2009, at 05:13 AM
By: AlphaBeta