trying to data log to sd every millisecond and having problems

jremington:
What is your thinking here? Do you not realize that the integer divide will always give 0 as a result?

 val = analogRead(A0);

volts = (val/1040);

Missed that! :o

Mixing float in is not going to make it faster. Don't let the Arduino do math just because you need understandable units. Of at least do it the other way around so the compiler can do the heavy calculation:

if(analogRead(TestPin) >= (1024 * 2.5 / 5)){

But if you just want to detect >2,5V the analog comparator is faster.