Closed technoblogy closed 5 years ago
The same thing happens on the Adafruit ItsyBitsy M4; the solution on that platform is to add a while (!Serial); statement which waits for the serial to initialise:
void setup() {
Serial.begin(9600);
while (!Serial);
}
void loop() {
for (int x=1; x<1000; x++) {
Serial.println(x);
delay(1000);
}
}
Unfortunately this has no effect on the MAX32620FTHR.
Call Serial.availableForWrite()
to get the number of bytes (characters) available for writing.
As an example:
void setup() {
Serial.begin(9600);
while(!Serial.availableForWrite());
}
I think you should still support while (!Serial) because this is what most people use. See:
https://www.arduino.cc/reference/en/language/functions/communication/serial/ifserial/
Otherwise my program, which is designed to run on several Arduino boards, will have to have special code and preprocessor directives to handle the MAX32620FTHR board.
Thanks for your suggestion! We will include this in our next update, once we resolve the issue #5.
The following simple test using the Arduino IDE Serial Monitor demonstrates this:
It prints: 3, 4, etc.
I uploaded the program by exporting it with Export compiled Binary and pasted it onto the BOOTLOADER disk.