I have an arduino Yun and I am trying to read voltage at a high sampling rate and write it to an sd card. Unfortunately I am relatively new to arduinos and optimizing the code for speed. I am seeing that if I use analogRead it will print to Serial at 1000 Hz, but when I try to write to the sd card after each sample, it varies between 2-4 Hz. My understanding is it takes time to open the file on the sd card and write to it and close it again and to get up to 1000 Hz.
How can I get a sampling rate of up to 1000 Hz and write to the sd card? I have read posts from others who have done it, but I can't compile their uploaded code and I don't understand the errors I am getting.