11/*
22 SD card test
33
4- This example shows how use the utility libraries on which the'
5- SD library is based in order to get info about your SD card.
6- Very useful for testing a card when you're not sure whether its working or not.
4+ This example shows how use the utility libraries on which the'
5+ SD library is based in order to get info about your SD card.
6+ Very useful for testing a card when you're not sure whether its working or not.
77
8- The circuit:
9- * SD card attached to SPI bus as follows:
8+ The circuit:
9+ SD card attached to SPI bus as follows:
1010 ** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila
1111 ** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila
1212 ** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila
1313 ** CS - depends on your SD card shield or module.
1414 Pin 4 used here for consistency with other Arduino examples
1515
1616
17- created 28 Mar 2011
18- by Limor Fried
19- modified 9 Apr 2012
20- by Tom Igoe
21- */
17+ created 28 Mar 2011
18+ by Limor Fried
19+ modified 9 Apr 2012
20+ by Tom Igoe
21+ */
2222// include the SD library:
2323#include < SPI.h>
2424#include < SD.h>
@@ -58,7 +58,8 @@ void setup() {
5858 }
5959
6060 // print the type of card
61- Serial.print (" \n Card type: " );
61+ Serial.println ();
62+ Serial.print (" Card type: " );
6263 switch (card.type ()) {
6364 case SD_CARD_TYPE_SD1:
6465 Serial.println (" SD1" );
@@ -79,25 +80,30 @@ void setup() {
7980 return ;
8081 }
8182
83+ Serial.print (" Clusters: " );
84+ Serial.println (volume.clusterCount ());
85+ Serial.print (" Blocks x Cluster: " );
86+ Serial.println (volume.blocksPerCluster ());
87+
88+ Serial.print (" Total Blocks: " );
89+ Serial.println (volume.blocksPerCluster () * volume.clusterCount ());
90+ Serial.println ();
8291
8392 // print the type and size of the first FAT-type volume
8493 uint32_t volumesize;
85- Serial.print (" \n Volume type is FAT" );
94+ Serial.print (" Volume type is: FAT" );
8695 Serial.println (volume.fatType (), DEC);
87- Serial.println ();
8896
8997 volumesize = volume.blocksPerCluster (); // clusters are collections of blocks
9098 volumesize *= volume.clusterCount (); // we'll have a lot of clusters
91- volumesize *= 512 ; // SD card blocks are always 512 bytes
92- Serial.print (" Volume size (bytes): " );
99+ volumesize /= 2 ; // SD card blocks are always 512 bytes (2 blocks are 1KB)
100+ Serial.print (" Volume size (Kb): " );
93101 Serial.println (volumesize);
94- Serial.print (" Volume size (Kbytes): " );
102+ Serial.print (" Volume size (Mb): " );
95103 volumesize /= 1024 ;
96104 Serial.println (volumesize);
97- Serial.print (" Volume size (Mbytes): " );
98- volumesize /= 1024 ;
99- Serial.println (volumesize);
100-
105+ Serial.print (" Volume size (Gb): " );
106+ Serial.println ((float )volumesize / 1024.0 );
101107
102108 Serial.println (" \n Files found on the card (name, date and size in bytes): " );
103109 root.openRoot (volume);
@@ -106,7 +112,5 @@ void setup() {
106112 root.ls (LS_R | LS_DATE | LS_SIZE);
107113}
108114
109-
110115void loop (void ) {
111-
112116}
0 commit comments