@@ -29,48 +29,50 @@ void setup()
2929 // Note that even if it's not used as the CS pin, the hardware SS pin
3030 // (10 on most Arduino boards, 53 on the Mega) must be left as an output
3131 // or the SD library functions will not work.
32+ pinMode(10 , OUTPUT );
3233
3334 if (! SD . begin(4 )) {
3435 Serial . println(" initialization failed!" );
3536 return ;
3637 }
3738 Serial . println(" initialization done." );
38-
39+
3940 if (SD . exists(" example.txt" )) {
40- Serial . println(" example.txt exists." );
41+ Serial . println(" example.txt exists." );
4142 }
4243 else {
43- Serial . println(" example.txt doesn't exist." );
44+ Serial . println(" example.txt doesn't exist." );
4445 }
45-
46+
4647 // open a new file and immediately close it:
4748 Serial . println(" Creating example.txt..." );
48- myFile = SD . open(" example.txt" , FILE_TRUNCATE );
49- myFile. close();
50-
49+ myFile = SD . open(" example.txt" , FILE_TRUNCATE );
50+ myFile. close();
51+
5152 // Check to see if the file exists:
5253 if (SD . exists(" example.txt" )) {
53- Serial . println(" example.txt exists." );
54+ Serial . println(" example.txt exists." );
5455 }
5556 else {
56- Serial . println(" example.txt doesn't exist." );
57+ Serial . println(" example.txt doesn't exist." );
5758 }
58-
59+
5960 // delete the file:
6061 Serial . println(" Removing example.txt..." );
6162 SD . remove(" example.txt" );
6263
6364 if (SD . exists(" example.txt" )){
64- Serial . println(" example.txt exists." );
65+ Serial . println(" example.txt exists." );
6566 }
6667 else {
67- Serial . println(" example.txt doesn't exist." );
68+ Serial . println(" example.txt doesn't exist." );
6869 }
6970}
7071
7172void loop ()
7273{
73- // nothing happens after setup finishes.
74+ // nothing happens after setup finishes.
7475}
7576
7677
78+
0 commit comments