SD Card Basics

Access SD card using SPI on Arduino;

  • Print the SD card type
  • Print the file system type
  • Print volume size
  • Print the entire file tree
  • Try to open a file (if it doesn't exist, create it)
  • Write a new line to it containing a random number
  • Print the whole file out

 

Arduino code here.

 

Serial output:

Initializing SD card...Wiring is correct and a card is present.

Card type: SD1

Volume type is FAT16

Volume size (bytes): 1015283712
Volume size (Kbytes): 991488
Volume size (Mbytes): 968

Files found on the card (name, date and size in bytes): 
DCIM/         2005-01-01 00:00:12
  100CASIO/     2005-05-01 00:00:16
    DINO.JPG      2005-01-01 00:09:14 1733080
    CIMG1317.JPG  2005-01-01 00:01:58 2469150
    CIMG1318.JPG  2005-01-01 00:02:28 1747318
    CIMG1319.JPG  2005-01-01 00:02:50 3848472
    CIMG1326.JPG  2005-01-01 00:07:46 1849686
    CIMG1327.JPG  2005-01-01 00:07:54 1739984
    CIMG1328.JPG  2005-01-01 00:08:12 1518549
    JOSE.JPG      2005-01-01 00:01:18 3524495
    _JOSE~1.JPG   2007-08-11 15:31:10 82
    BUNIT~1.JPG   2005-01-01 00:05:22 1848172
    _BUNIT~1.JPG  2007-08-11 15:32:20 82
    _DINO~1.JPG   2007-08-11 15:34:04 82
    DS_STO~1      2007-08-11 16:14:32 21508
    SIV29.TMP     2007-07-25 17:43:48 1101824
    SIV14.TMP     2007-07-30 20:25:16 176128
  DS_STO~1      2007-08-11 16:14:38 6148
TRASHE~1/     2006-08-14 19:50:20
  501/          2006-08-19 11:59:20
  _501~1        2006-08-19 11:59:20 82
_~1.TRA       2006-08-14 19:50:20 4096
DS_STO~1      2007-08-11 15:30:16 6148
EXAMPLE.TXT   2000-01-01 01:00:00 43
WMPINFO.XML   2006-08-22 14:50:38 296
example.txt exists.
 
807
673
708
462