To read the data saved on your file: dataFile.read() You can also use the print() or println() functions to print data into the file: dataFile.print(data) ĭataFile.println(data) // followed by a new line In which the dataFile is the file object created previously and the data is what you want to write in the file. To write data to the currently open file, you use: dataFile.write(data) If the data.txt file already exists, Arduino will open the file instead of creating another one. This line of code creates a file called data.txt on your SD card. The first parameter of this function is the name of the file, data.txt, and the FILE_WRITE argument enables you to read and write into the file. For example: dataFile = SD.open("data.txt", FILE_WRITE) To open a new file in the SD card, you need to create a file object that refers to your data file. You also have to initialize the SD card module at the Chip Select (CS) pin – in our case, pin 4. To write and read from the SD card, first you need to include the SPI and SD libraries: #include The SD library provides useful functions for easily write in and read from the SD card.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |