The File.readBytesUntil() function reads characters from a file into a buffer. The function terminates if the terminator character is detected, the determined length has been read, or it times out (see setTimeout()). The function returns the characters up to the last character before the supplied terminator. The terminator itself is not returned in the buffer.
The File.readBytesUntil() function returns the number of bytes placed in the buffer. A 0 means no valid data was found.
The File.readBytesUntil() function inherits from the Stream utility class.
file.readBytesUntil(character, buffer, length)
- file: an instance of a class that inherits from File.
- character: the character to search for. Allowed data types: char.
- buffer: the buffer to store the bytes in. Allowed data types: array of char or byte.
- length: the number of bytes to read. Allowed data types: int.
- The number of bytes placed in the buffer.
Notes and Warnings
The terminator character is discarded from the return
- Connect the SD Card to your your PC via an USB 3.0 SD Card Reader
Create a arduino.txt file with the below content
- Connect SD Card to Arduino. See Arduino - Micro SD Card tutorial
- Upload below code to Arduino via Arduino IDE
- Open Serial Monitor, you will see as below: