File tree Expand file tree Collapse file tree 6 files changed +40
-54
lines changed Expand file tree Collapse file tree 6 files changed +40
-54
lines changed Original file line number Diff line number Diff line change @@ -34,8 +34,7 @@ SdFile root;
34
34
// Sparkfun SD shield: pin 8
35
35
const int chipSelect = 4 ;
36
36
37
- void setup ()
38
- {
37
+ void setup () {
39
38
// Open serial communications and wait for port to open:
40
39
Serial.begin (9600 );
41
40
while (!Serial) {
Original file line number Diff line number Diff line change 25
25
26
26
const int chipSelect = 4 ;
27
27
28
- void setup ()
29
- {
28
+ void setup () {
30
29
// Open serial communications and wait for port to open:
31
30
Serial.begin (9600 );
32
31
while (!Serial) {
@@ -45,8 +44,7 @@ void setup()
45
44
Serial.println (" card initialized." );
46
45
}
47
46
48
- void loop ()
49
- {
47
+ void loop () {
50
48
// make a string for assembling the data to log:
51
49
String dataString = " " ;
52
50
Original file line number Diff line number Diff line change 25
25
26
26
const int chipSelect = 4 ;
27
27
28
- void setup ()
29
- {
28
+ void setup () {
30
29
// Open serial communications and wait for port to open:
31
30
Serial.begin (9600 );
32
31
while (!Serial) {
@@ -61,7 +60,6 @@ void setup()
61
60
}
62
61
}
63
62
64
- void loop ()
65
- {
63
+ void loop () {
66
64
}
67
65
Original file line number Diff line number Diff line change 22
22
23
23
File myFile;
24
24
25
- void setup ()
26
- {
25
+ void setup () {
27
26
// Open serial communications and wait for port to open:
28
27
Serial.begin (9600 );
29
28
while (!Serial) {
@@ -41,8 +40,7 @@ void setup()
41
40
42
41
if (SD.exists (" example.txt" )) {
43
42
Serial.println (" example.txt exists." );
44
- }
45
- else {
43
+ } else {
46
44
Serial.println (" example.txt doesn't exist." );
47
45
}
48
46
@@ -54,8 +52,7 @@ void setup()
54
52
// Check to see if the file exists:
55
53
if (SD.exists (" example.txt" )) {
56
54
Serial.println (" example.txt exists." );
57
- }
58
- else {
55
+ } else {
59
56
Serial.println (" example.txt doesn't exist." );
60
57
}
61
58
@@ -65,14 +62,12 @@ void setup()
65
62
66
63
if (SD.exists (" example.txt" )) {
67
64
Serial.println (" example.txt exists." );
68
- }
69
- else {
65
+ } else {
70
66
Serial.println (" example.txt doesn't exist." );
71
67
}
72
68
}
73
69
74
- void loop ()
75
- {
70
+ void loop () {
76
71
// nothing happens after setup finishes.
77
72
}
78
73
Original file line number Diff line number Diff line change 23
23
24
24
File myFile;
25
25
26
- void setup ()
27
- {
26
+ void setup () {
28
27
// Open serial communications and wait for port to open:
29
28
Serial.begin (9600 );
30
29
while (!Serial) {
@@ -73,8 +72,7 @@ void setup()
73
72
}
74
73
}
75
74
76
- void loop ()
77
- {
75
+ void loop () {
78
76
// nothing happens after setup
79
77
}
80
78
Original file line number Diff line number Diff line change 1
1
/*
2
2
Listfiles
3
-
4
- This example shows how print out the files in a
5
- directory on a SD card
6
-
3
+
4
+ This example shows how print out the files in a
5
+ directory on a SD card
6
+
7
7
The circuit:
8
8
* SD card attached to SPI bus as follows:
9
9
** MOSI - pin 11
17
17
by Tom Igoe
18
18
modified 2 Feb 2014
19
19
by Scott Fitzgerald
20
-
20
+
21
21
This example code is in the public domain.
22
22
23
23
*/
26
26
27
27
File root;
28
28
29
- void setup ()
30
- {
29
+ void setup () {
31
30
// Open serial communications and wait for port to open:
32
31
Serial.begin (9600 );
33
32
while (!Serial) {
@@ -49,33 +48,32 @@ void setup()
49
48
Serial.println (" done!" );
50
49
}
51
50
52
- void loop ()
53
- {
51
+ void loop () {
54
52
// nothing happens after setup finishes.
55
53
}
56
54
57
55
void printDirectory (File dir, int numTabs) {
58
- while (true ) {
59
-
60
- File entry = dir.openNextFile ();
61
- if (! entry) {
62
- // no more files
63
- break ;
64
- }
65
- for (uint8_t i= 0 ; i< numTabs; i++) {
66
- Serial.print (' \t ' );
67
- }
68
- Serial.print (entry.name ());
69
- if (entry.isDirectory ()) {
70
- Serial.println (" /" );
71
- printDirectory (entry, numTabs+ 1 );
72
- } else {
73
- // files have sizes, directories do not
74
- Serial.print (" \t\t " );
75
- Serial.println (entry.size (), DEC);
76
- }
77
- entry.close ();
78
- }
56
+ while (true ) {
57
+
58
+ File entry = dir.openNextFile ();
59
+ if (! entry) {
60
+ // no more files
61
+ break ;
62
+ }
63
+ for (uint8_t i = 0 ; i < numTabs; i++) {
64
+ Serial.print (' \t ' );
65
+ }
66
+ Serial.print (entry.name ());
67
+ if (entry.isDirectory ()) {
68
+ Serial.println (" /" );
69
+ printDirectory (entry, numTabs + 1 );
70
+ } else {
71
+ // files have sizes, directories do not
72
+ Serial.print (" \t\t " );
73
+ Serial.println (entry.size (), DEC);
74
+ }
75
+ entry.close ();
76
+ }
79
77
}
80
78
81
79
You can’t perform that action at this time.
0 commit comments