Serial.end()

Description

Disables serial communication, allowing the RX and TX pins to be used for general input and output. To re-enable serial communication, call Serial.begin().

Syntax

Use the following function to disable the Serial communication:

Serial.end()

Parameters

The function admits the following object:

Serial
: serial port object. See the list of available serial ports for each board on the Serial main page.

Returns

The function returns nothing.

Example Code

The following code disables and then enables serial communication.

1void setup() {
2 Serial.begin(9600);
3 delay(1000); // Allow time for Serial Monitor to connect
4 Serial.println("Hello from Serial!");
5
6 Serial.end(); // Stop communication
7
8 delay(2000); // Simulate doing something else...
9
10 Serial.begin(9600); // Re-initialize serial
11 Serial.println("Serial restarted!");
12}
13
14void loop() {
15}

Suggest changes

The content on docs.arduino.cc is facilitated through a public GitHub repository. If you see anything wrong, you can edit this page here.

License

The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.

ON THIS PAGE