My sketch looks somehow like this:
ClassA classA;
void setup() {
Serial.begin(9600);
classA = ClassA();
Serial.println("Bar")
...
}
void loop() {
classA.functionFoo();
}
The constructor of ClassA
however calls some internal methods that perform a Serial.println()
.
My problem is, that the first (implicit) call of the constructor of ClassA
comes in the first line of the sketch with
ClassA classA;
This is before the Serial interface has been initialized (with Serial.begin(9600)
). Therefore the Serial.monitor cannot interpret the first messages coming from the serial interface.
How can I either suppress any Serial.writes before the setup function or otherwise make sure that the Serial interface is initialized before the setup function?
classA
a pointer and create the new object withnew
.