BriComp
Well-known member
Code:
#include "Arduino.h"
#include <SD.h>
#include <SPI.h>
const int chipSelect = BUILTIN_SDCARD;
File f1, f2;
void setup()
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect.
}
Serial.print("Initializing SD card...");
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
} else {
Serial.println();
}
f1 = SD.open("File1", FILE_WRITE);
f2 = SD.open("File2", FILE_WRITE);
Serial.print("File1 = "); Serial.println(f1);
Serial.print("File2 = "); Serial.println(f2);
f1.close();
f2.close();
}
// Add the main program code into the continuous loop() function
void loop()
{
}
I thought that it was possible to have more than one SD card file open at the same time but indications indicated that that might not be so.
As a quick test I wrote the above small program and the file identifiers f1 and f1 are returning the same value.
What might be going wrong? I am using Teensyduino 1.54b11.
Below is the output from the above sketch. Both files are created on the SD cards, but with the same identifiers I can only access 1.
PS I should have added that I am using a Teensy 3.5Initializing SD Card...
File1 = 1
File2 = 1
Last edited: