Javatpoint Logo
Javatpoint Logo

Serial.available( )

The Serial.available( ) function in Arduino gets the stored bytes from the serial port that are available for reading. It is the data, which is already stored and arrived in the serial buffer. The serial buffer in Arduino holds the 64 bytes.

Serial.available( ) function inherits from the utility class called stream. The stream is only invoked when the function relying on it is called. The stream class is considered as the base class for binary and character-based streams.

Serial.available( )

Let's understand with an example.

Consider the below code.

In case of the Arduino Mega, the ports available are:

Serial1.available( )

Serial2.available( )

Serial3.available( )

Let's understand the concept of Mega with an example.

In this example, the data will be read and sent from one port to another.

It will read data from port 0 and will then send the data to port 1.

Consider the below code.

We can also check the errors in our code by compiling. For that, click on the Verify button.

The Arduino screen will look like the below image:

Serial.available( )

The Done Compiling will signify the successful compiling of the code.

Note: With the help of the Arduino board, we cannot connect the serial device to our computer.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA