SD card not being read properly


i trying read numbers off sd card , i'm running trouble. ran cardinfo , had no problems (i've attached log below). on sd card, frames.txt has "200" inside it, , frame.txt has "00000010". when run program, serial monitor shows 48 frame.txt (instead of 2) , shows  50 frames.txt(instead of 200). here code, going wrong?
code: [select]
#include <sd.h>

file myfile;

void setup(){
  serial.begin(9600);
  pinmode(10,output);
  if(!sd.begin(10))
  serial.println("initialization failed.");
  else
  serial.println("initialization complete.");
  myfile = sd.open("frames.txt");
  if (myfile) {
    serial.println("frames.txt:");
}
else
serial.println("failure");
byte k=myfile.read();
serial.println(k);
}

void loop(){
}


cardinfo log:

initializing sd card...wiring correct , card present.

card type: sd1

volume type fat16

volume size (bytes): 513015808
volume size (kbytes): 500992
volume size (mbytes): 489

files found on card (name, date , size in bytes):
frames.txt    2013-06-14 16:34:44 3
matrix.txt    2013-06-14 15:15:58 1924
frame.txt     2013-06-14 16:36:22 8

48 ascii equivalent of '0'.  50 ascii equivalent of '2'.

if define k char instead of byte, serial.println() print char instead of unsigned char.


Arduino Forum > Using Arduino > Programming Questions > SD card not being read properly


arduino

Comments

Popular posts from this blog

Rasperry Wifi LAN Controller - Raspberry Pi Forums

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

Unlock car with bluetooth and car key