Serial is documented on the Reference pages, but seems to receive special treatment (no need to include header), and there does not seem to be any file with the Source code.

Stream is the base class for Serial and inherits from the Print class.

There is source for Stream.h

LiquidCrystal_I2C also inherits from the Print class, and I was planning to write code which outputs to either LiquidCrystal_I2C or Serial; there are many options, but I was looking for Serial to explore its inner workings.


1 Answer 1


Serial is an instance of the HardwareSerial class. It is defined in HardwareSerial0.cpp:

#if defined(UBRRH) && defined(UBRRL)
  HardwareSerial Serial(&UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR);
  HardwareSerial Serial(&UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UCSR0C, &UDR0);

HardwareSerial is a child of Stream as defined in HardwareSerial.h:

class HardwareSerial : public Stream

Stream is a child of Print as defined in Stream.h:

class Stream : public Print

Print is a top-level class with no inheritance.

Serial is not a class. It is an instance of a class. That is, it's an object that has been constructed from the class definition. Anything you access member functions of using a . is an instance of a class (aka an object) not a class itself. Anything you access member functions with :: is a class using static member functions.


Serial.println(); // Call the println() function in the Serial object
Wire.beginTransmission(0x34); // Call the beginTransmission function in the Wire object
Foo::bar(); // Call the static function bar() in the Foo class.

Not the answer you're looking for? Browse other questions tagged or ask your own question.