Can two Arduinos share an SD card? Locking mechanism?

fat16lib:
It will be very difficult to make this work. The SPI bus can only have one master so you will need to disable the SPI bus on the Arduino that is not accessing the SD.

You will need to close all files, disable the SPI controller on one Arduino and set the state of all SPI pins and chip select to inputs.

You then need to initialize the SD card and open files on the other Arduiono.

There is probably more that I haven't thought of.

Hi, I tried this method. However, I can only access to the sd card once.
Here is my system: arduino1 and arduino2
arduino1 was writing the file
arduino2 sent a "$" to arduino1
arduino1 recieved "$" and put SDCS, SDDI, SDDO, SDCLK into input. Then it did spi.end() and sent a "#" to arduino2
arduino2 recieved "#" and put SDCS, SDDI, SDDO, SDCLK into output. Then it did SD.begin(10) and started reading file
After arduino2 read the file, it put SDCS, SDDI, SDDO, SDCLK into input, and did a spi.end(). After that, it sent a "#" to arduino1
arduino1 recieved "#" and put SDCS, SDDI, SDDO, SDCLK into output. It did a SD.begin(10), and started to write to the sd card again

This procedure can only work once. I checked sd.begin in the arduino1 for the last step. It returned false. Also, when during the second time the communication started, the SD.begin returned false in arduino2.

How can i make this work? I think there might be something wrong with multiple SD.begin.