Commit 9b03747a authored by Markéta Jedličková's avatar Markéta Jedličková
Browse files

New name of file changed from test.txt to data.txt

parent 82b15ea6
......@@ -38,20 +38,21 @@ void setup()
// begin communication with the SD card using the previously specified pin
// print an error to the serial in case the SD card is not found
if (!SD.begin(cs_pin)) {
if (!SD.begin(cs_pin))
{
Serial.println("SD card initialization failed!");
return;
}
Serial.println("SD card initialized");
file = SD.open("test.txt", FILE_WRITE); // open test.txt for write
file = SD.open("data.txt", FILE_WRITE); // open test.txt for write
// write to the file and print info to serial
// print an error to the serial in case it does not succeed
if (file)
{
Serial.println("Writing to test.txt");
Serial.println("Writing to data.txt");
file.println("openCanSat SD card test");
file.close();
......@@ -59,26 +60,26 @@ void setup()
}
else
{
Serial.println("Error opening test.txt for writing");
Serial.println("Error opening data.txt for writing");
}
// read the test.txt and print it to serial
// print an error to the serial in case it does not succeed
file = SD.open("test.txt");
if (file)
file = SD.open("data.txt");
if (file)
{
Serial.println("test.txt:");
Serial.println("data.txt :");
while (file.available())
{
Serial.write(file.read());
}
file.close();
Serial.println("Reading from test.txt finished");
Serial.println("Reading from data.txt finished");
}
else
{
Serial.println("Error opening test.txt for reading");
Serial.println("Error to open data.txt");
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment