The Serial.read( ) in Arduino reads the incoming serial data in the Arduino. The int data type is used here. It returns the first data byte of the arriving serial data. It also returns -1 when no data is available on the serial port.
The syntax used in the Arduino programming is Serial.read( ) Where, serial: It signifies the serial port object. The data is stored in the form of bytes, where 1 byte = 8 bits.
In this lesson I will write some code to clearly explain how the Serial.available( ) is used to get the available number of bytes if it is greater than 0. The Serial.read( ) function will read the data from the data byte and print a message if the data is received. The data is sent from the serial monitor to the Arduino.