Wanted to write 2 SD cards from one Arduino (Mega or other) with the SD library. Also want to be able to copy a file from one SD card to another.
I used a MEGA. Attached the 2 SD cards as per standard instructions except for 1 pin:
SD number 1, CS (chip-select) pin is connected to 53 and
SD number 2, CS pin is connected to 13 (or any other unused digital pin).
Note that the SD cards need 3.3 Volt as VCC but they cab handle 5V on the logical pins (or at least the ones I used).
In the sketch, only one SD card can be open at the same time, SD.begin(53). However, by doing a digitalWrite(53, HIGH) before the SD.begin(13), the first one is de-selected and the other SD card will be selected. When switching back to the first SD card, do a digitalWrite(13, HIGH) before the SD.begin(53).
Also make sure to close any open files fileName.close() when data has been written to a file before switching to the other SD card.
In fact more than 2 SD cards can be attached this way as long as the CS pins are connected to different pins.
Comments