Port Serial: USART - Universal Serial Asynchronous Receiver Transmitter Section 24 of Datasheet
Port Serial: USART - Universal Serial Asynchronous Receiver Transmitter Section 24 of Datasheet
available()
Description : Get the number of bytes (characters) available for reading from the serial port. This is data that's
already arrived and stored in the serial receive buffer (which holds 64 bytes). available() inherits from the Stream
utility class.
Syntax : Serial.available()
Parameters : none
Returns : the number of bytes available to read
Arduino Functions
availableForWrite()
Description : Get the number of bytes (characters) available for writing
in the serial buffer without blocking the write operation.
Syntax : Serial.availableForWrite()
Parameters : none
Returns : the number of bytes available to write
Arduino Functions
begin()
Description : Sets the data rate in bits per second (baud) for serial data transmission. For communicating with the
computer, use one of these rates: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200.
You can, however, specify other rates - for example, to communicate over pins 0 and 1 with a component that requires a
particular baud rate.
• An optional second argument configures the data, parity, and stop bits. The default is 8 data bits, no parity, one stop bit.
Syntax : Serial.begin(speed)
Serial.begin(speed, config)
Parameters : speed : baud rate (in bits per second) - long;
config: sets data (5, 6, 7, 8, or 9), parity (N, E, O), and stop bits (1, 2).
Valid values are : SERIAL_5N1, SERIAL_6N1, SERIAL_7N1, SERIAL_8N1 (the default), SERIAL_5N2,
SERIAL_6N2, SERIAL_7N2, SERIAL_8N2, SERIAL_5E1, SERIAL_6E1, SERIAL_7E1, SERIAL_8E1,
SERIAL_5E2, SERIAL_6E2, SERIAL_7E2, SERIAL_8E2, SERIAL_5O1, SERIAL_6O1, SERIAL_7O1,
SERIAL_8O1, SERIAL_5O2, SERIAL_6O2, SERIAL_7O2, SERIAL_8O2
Returns : nothing
Arduino Functions
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() without parameter.
Syntax : Serial.end()
Parameters : none
Returns : nothing
find()
Description : Serial.find() reads data from the serial buffer until the target string of given length is found. The
function returns true if target string is found, false if it times out.
• Serial.find() inherits from the Stream utility class.
Syntax : Serial.find(target)
Parameters : target : the string to search for (char)
Returns : boolean
Arduino Functions
findUntil()
Description : Serial.findUntil() reads data from the serial buffer until a target string of given length or terminator
string is found.
• The function returns true if the target string is found, false if it times out.
• Serial.findUntil() inherits from the Stream utility class.
Syntax : Serial.findUntil(target, terminal)
Parameters : target : the string to search for (char)
terminal : the terminal string in the search (char)
Returns : boolean
flush()
Description : Waits for the transmission of outgoing serial data to complete. (Prior to Arduino 1.0, this instead
removed any buffered incoming serial data.)
• flush() inherits from the Stream utility class.
Syntax : Serial.flush()
Parameters : none
Returns : nothing
Arduino Functions
parseFloat()
Description : Serial.parseFloat() returns the first valid floating point
number from the Serial buffer. Characters that are not digits (or the
minus sign) are skipped. parseFloat() is terminated by the first character
that is not a floating point number.
• Serial.parseFloat() inherits from the Stream utility class.
Syntax : Serial.parseFloat()
Parameters : none
Returns : float
Arduino Functions
parseInt()
Description : Looks for the next valid integer in the incoming serial stream. parseInt() inherits from the
Stream utility class.
In particular:
• Initial characters that are not digits or a minus sign, are skipped;
• Parsing stops when no characters have been read for a configurable time-out value, or a non-digit is
read;
• If no valid digits were read when the time-out (see Serial.setTimeout()) occurs, 0 is returned;
Syntax : Serial.parseInt()
Serial.parseInt(char skipChar)
Parameters : skipChar: used to skip the indicated char in the search. Used for example to skip thousands
divider.
Returns : long : the next valid integer
Arduino Functions
peek()
Description : Returns the next byte (character) of incoming serial data without removing it
from the internal serial buffer. That is, successive calls to peek() will return the same
character, as will the next call to read().
peek() inherits from the Stream utility class.
Syntax : Serial.peek()
Parameters : None
Returns : the first byte of incoming serial data available (or -1 if no data is available) - int