PaulS:
if (analogRead( detect) == 0)What, EXACTLY, is connected to this pin? Why doesn't the detect variable have pin in the name, to make it clear that it holds a pin number?
Why are you expecting an analog value of exactly 0?
.
.
.
etc
There is not a snowball's chance in hell that the code you posted will compile. Why are you wasting our time?
Sorry, I had to remove things to get it below the 9000 char limit for posts so I got rid of boring code. I just now edited the code to put back all the code but took out all comments which of course makes following the code much harder.
I have a switch onboard that when I was recording to SD card I would flip it to stop recording while I removed card. I no longer do that. Don't know why I used analogread!