Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Bie
Published

Desktop SD Card Scanner

This desktop scanner reads files from an SD card to show you what is on it without connecting it to a device. Just slide it in and watch!

IntermediateShowcase (no instructions)829
Desktop SD Card Scanner

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
20+ wires
×20
SD card reader
×1
Hand potentiometer
×1

Story

Read more

Code

Desktop Scanner Code

C/C++
//BasementResearch (10/22/18)
//With code from Arduino->Files->Examples->SD->listfiles

#include <LiquidCrystal.h>
#include <SD.h>

LiquidCrystal lcd(5,6,7,8,9,10);

File root;

void clear(){
  lcd.clear();
  lcd.setCursor(0,0);
}

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

void setup(){
  lcd.begin(16,2);
  
  
}

void loop(){
  
  lcd.setCursor(0,0);
  lcd.print("Testing card,");
  lcd.setCursor(0,1);
  lcd.print("Please wait...");
  delay(2000);
  pinMode(10, OUTPUT);
  clear();
  int y = 1;
  while(!SD.begin(4)){
    lcd.print("No card in drive...");
    lcd.setCursor(0,1);
    lcd.print("Insert card");
    lcd.setCursor(0,0);
  }clear();
  lcd.print("Card in drive,");
  lcd.setCursor(0,1);
  lcd.print("Please wait...");
  
  delay(2000);
  clear();
  root = SD.open("/");
  delay(1000);
  printDirectory(root, 0);
  clear();
   lcd.print("Please remove");
   lcd.setCursor(0,1);
   lcd.print("card from drive.");
   delay(5000);
}

Credits

Bie
2 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.