11/*
2- SD card test
3-
2+ SD card test
3+
44 This example shows how use the utility libraries on which the'
55 SD library is based in order to get info about your SD card.
66 Very useful for testing a card when you're not sure whether its working or not.
7-
7+
88 The circuit:
99 * 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
13- ** CS - depends on your SD card shield or module.
13+ ** CS - depends on your SD card shield or module.
1414 Pin 4 used here for consistency with other Arduino examples
1515
16-
16+
1717 created 28 Mar 2011
18- by Limor Fried
18+ by Limor Fried
1919 modified 9 Apr 2012
2020 by Tom Igoe
2121 */
22- // include the SD library:
22+ // include the SD library:
23+ #include < SPI.h>
2324#include < SD.h>
2425
2526// set up variables using the SD utility library functions:
@@ -31,22 +32,22 @@ SdFile root;
3132// Arduino Ethernet shield: pin 4
3233// Adafruit SD shields and modules: pin 10
3334// Sparkfun SD shield: pin 8
34- const int chipSelect = 4 ;
35+ const int chipSelect = 4 ;
3536
3637void setup ()
3738{
38- // Open serial communications and wait for port to open:
39+ // Open serial communications and wait for port to open:
3940 Serial.begin (9600 );
40- while (!Serial) {
41+ while (!Serial) {
4142 ; // wait for serial port to connect. Needed for Leonardo only
4243 }
4344
4445
4546 Serial.print (" \n Initializing SD card..." );
4647 // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
47- // Note that even if it's not used as the CS pin, the hardware SS pin
48- // (10 on most Arduino boards, 53 on the Mega) must be left as an output
49- // or the SD library functions will not work.
48+ // Note that even if it's not used as the CS pin, the hardware SS pin
49+ // (10 on most Arduino boards, 53 on the Mega) must be left as an output
50+ // or the SD library functions will not work.
5051 pinMode (10 , OUTPUT); // change this to 53 on a mega
5152
5253
@@ -59,12 +60,12 @@ void setup()
5960 Serial.println (" * did you change the chipSelect pin to match your shield or module?" );
6061 return ;
6162 } else {
62- Serial.println (" Wiring is correct and a card is present." );
63+ Serial.println (" Wiring is correct and a card is present." );
6364 }
6465
6566 // print the type of card
6667 Serial.print (" \n Card type: " );
67- switch (card.type ()) {
68+ switch (card.type ()) {
6869 case SD_CARD_TYPE_SD1:
6970 Serial.println (" SD1" );
7071 break ;
@@ -90,7 +91,7 @@ void setup()
9091 Serial.print (" \n Volume type is FAT" );
9192 Serial.println (volume.fatType (), DEC);
9293 Serial.println ();
93-
94+
9495 volumesize = volume.blocksPerCluster (); // clusters are collections of blocks
9596 volumesize *= volume.clusterCount (); // we'll have a lot of clusters
9697 volumesize *= 512 ; // SD card blocks are always 512 bytes
@@ -103,15 +104,15 @@ void setup()
103104 volumesize /= 1024 ;
104105 Serial.println (volumesize);
105106
106-
107+
107108 Serial.println (" \n Files found on the card (name, date and size in bytes): " );
108109 root.openRoot (volume);
109-
110+
110111 // list all files in the card with date and size
111112 root.ls (LS_R | LS_DATE | LS_SIZE);
112113}
113114
114115
115116void loop (void ) {
116-
117+
117118}
0 commit comments