-
-
Notifications
You must be signed in to change notification settings - Fork 727
Closed
Labels
Description
The documentation of Serial.begin()
does not limit the use to one time - which is correct. However, it's not described how to use Serial.begin()
multiple times.
I have asked a Stack Exchange question about it. From the answer I got there, I would like the documentation to be enhanced like this:
Description
[...]
`Serial.begin()` can be used multiple times within a program.
Be aware that data that was already written might still be buffered.
Therefore, you might want to use `Serial.flush()` before changing the baud rate.
and add an example
Example Code
[...]
Changing the baud rate:
void loop() {
Serial.begin(1200);
Serial.println("Hello");
Serial.flush();
Serial.begin(9600);
Serial.println("world");
Serial.flush();
}
This could be useful e.g. if the two communication ends want to negotiate the baud rate. Forgetting to flush will likely cause effects that prevent successful negotiation.