I have the Arduino Ethernet Shield with an SD card reader.
I would like read the SD card only while the setup() process. As soon as the program runs the main loop I wish remove my SD card (for using it with another Arduino project or with my camera). Well, after reading my configuration my SD card is useless.
Which code I have to write for a clean eject? Just closing my ini file, some pins to power off?
During the setup my 13-led is HIGH. So while this led switch off, I know I can remove the card… if it is the right way.
Well, after reading my configuration my SD card is useless.
What does this mean? You need to throw it away and buy a new one?
Which code I have to write for a clean eject?
All that really needs to be done is close all open files, and make sure you never try to access the device in loop(). Setting the slave select pin HIGH again wouldn't hurt.
Another alternative:
Set a DoOnce variable at the start of the loop, have it open/read/close the file on the SD card, then set DoOnce again so it doesn't repeat it until next bootup.
Like:
int DoOnce;
void setup()
{
//Your code here
digitalWrite(13,HIGH); //Optional status led
}
void loop()
{
if (DoOnce==0)
{
//Your code to open, read, and close here
digitalWrite(13,LOW); //Goes along with the Setup status led
DoOnce=1;
}
//Rest of your code
}