mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
* Deprecate SPIFFS, move examples to LittleFS SPIFFS has been a great filesystem, but it has significant problems in many cases (and it's also pretty slow). Development seems to have slowed/stopped on the upstream version, and we're not able to provide support or fix the known issues with it as-is. Deprecate SPIFFS variable. Update all examples to use LittleFS instead of SPIFFS. Also, minor cleanup on very old examples which has obsolete delays waiting for the Serial port to come up, or which were stuck at 9600 baud because of their ancient AVR heritage. Fixes #7095 * Remove leftover debug code * Clean up comments in some examples * Update documentation on SPIFFS deprecation * Fix host tests to avoid deprecation warnings * Fix cut-n-paste error * Restore SpeedTest.ino, adjust to allow custom FSes Co-authored-by: Develo <deveyes@gmail.com>
72 lines
1.4 KiB
C++
72 lines
1.4 KiB
C++
/*
|
|
SD card basic file example
|
|
|
|
This example shows how to create and destroy an SD card file
|
|
The circuit:
|
|
SD card attached to SPI bus as follows:
|
|
** MOSI - pin 11
|
|
** MISO - pin 12
|
|
** CLK - pin 13
|
|
** CS - pin 4
|
|
|
|
created Nov 2010
|
|
by David A. Mellis
|
|
modified 9 Apr 2012
|
|
by Tom Igoe
|
|
|
|
This example code is in the public domain.
|
|
|
|
*/
|
|
#include <SPI.h>
|
|
#include <SD.h>
|
|
|
|
File myFile;
|
|
|
|
void setup() {
|
|
// Open serial communications and wait for port to open:
|
|
Serial.begin(115200);
|
|
|
|
Serial.print("Initializing SD card...");
|
|
|
|
if (!SD.begin(4)) {
|
|
Serial.println("initialization failed!");
|
|
return;
|
|
}
|
|
Serial.println("initialization done.");
|
|
|
|
if (SD.exists("example.txt")) {
|
|
Serial.println("example.txt exists.");
|
|
} else {
|
|
Serial.println("example.txt doesn't exist.");
|
|
}
|
|
|
|
// open a new file and immediately close it:
|
|
Serial.println("Creating example.txt...");
|
|
myFile = SD.open("example.txt", FILE_WRITE);
|
|
myFile.close();
|
|
|
|
// Check to see if the file exists:
|
|
if (SD.exists("example.txt")) {
|
|
Serial.println("example.txt exists.");
|
|
} else {
|
|
Serial.println("example.txt doesn't exist.");
|
|
}
|
|
|
|
// delete the file:
|
|
Serial.println("Removing example.txt...");
|
|
SD.remove("example.txt");
|
|
|
|
if (SD.exists("example.txt")) {
|
|
Serial.println("example.txt exists.");
|
|
} else {
|
|
Serial.println("example.txt doesn't exist.");
|
|
}
|
|
}
|
|
|
|
void loop() {
|
|
// nothing happens after setup finishes.
|
|
}
|
|
|
|
|
|
|