Page 383 - 최강 아두이노 퍼스트 참고서
P. 383

Serial.println("initialization done.");
                   root = SD.open("/");
                   printDirectory(root, 0);
                   Serial.println("done!");
                 }

                 void loop()
                 {
                   // nothing happens after setup finishes.
                 }

                 void printDirectory(File dir, int numTabs)
                 {
                   while(true)
                   {
                     File entry =  dir.openNextFile();
                     if (! entry)
                     {
                       // no more files
                       break;
                     }
                     for (uint8_t i=0; i<numTabs; i++)
                     {
                       Serial.print('\t');
                     }
                     Serial.print(entry.name());
                     if (entry.isDirectory())
                     {
                       Serial.println("/");
                       printDirectory(entry, numTabs+1);
                     }
                     else
                     {
                       // files have sizes, directories do not
                       Serial.print("\t\t");
                       Serial.println(entry.size(), DEC);
                     }
                     entry.close();
                   }
                 }
















                                                   383
   378   379   380   381   382   383   384   385   386   387   388