readStringUntil() reads characters from the serial buffer into a String. The function terminates (checks being done in this order) if one of the follwing condition is met:
- The timeout is elapsed (see Serial.setTimeout())
- The delimiter character is detected (in which case the function returns the characters up to the last character before the supplied delimiter). The delimiter itself is not returned in the buffer.
Serial.readStringUntil() inherits from the Stream utility class.
- Serial: serial port object. See the list of available serial ports for each board on the Serial main page.
- delimiter: the character to search for. Allowed data types: char.
- The entire String read from the serial buffer, up to the delimiter character
- Select Newline at the ending selection of Serial Monitor
- Type "HELLO" on Serial Monitor
- Click Send button:
- The result on Serial Monitor:
※ NOTES AND WARNINGS:
- The delimiter character is discarded from the serial buffer.
- Serial functions are not only used for the communication between an Arduino board and Serial Monitor of Arduino IDE but also used for the communication between:
- An Arduino board and other Arduino board
- An Arduino board and other sensors/devices
- An Arduino board and computer (any Serial software on computer)