Components and supplies
1
Hand potentiometer
1
SD card reader
20
Jumper wires (generic)
1
Arduino UNO
Project description
Code
Desktop Scanner Code
c_cpp
Comments
Only logged in users can leave comments
Components and supplies
Hand potentiometer
SD card reader
Jumper wires (generic)
Arduino UNO
Project description
Code
Desktop Scanner Code
c_cpp
1//BasementResearch (10/22/18) 2//With code from Arduino->Files->Examples->SD->listfiles 3 4#include <LiquidCrystal.h> 5#include <SD.h> 6 7LiquidCrystal lcd(5,6,7,8,9,10); 8 9File root; 10 11void clear(){ 12 lcd.clear(); 13 lcd.setCursor(0,0); 14} 15 16void printDirectory(File dir, int numTabs) { 17 while(true) { 18 19 File entry = dir.openNextFile(); 20 if (! entry) { 21 // no more files 22 //Serial.println("**nomorefiles**"); 23 break; 24 }/* 25 for (uint8_t i=0; i<numTabs; i++) { 26 lcd.print(' '); 27 }*/ 28 clear(); 29 lcd.print(entry.name()); 30 lcd.setCursor(0,1); 31 if (entry.isDirectory()) { 32 printDirectory(entry, numTabs+1); 33 } else { 34 // files have sizes, directories do not 35 lcd.print("Size: "); 36 lcd.println(entry.size(), DEC); 37 delay(700); 38 clear(); 39 } 40 entry.close(); 41 } 42 43} 44 45void setup(){ 46 lcd.begin(16,2); 47 48 49} 50 51void loop(){ 52 53 lcd.setCursor(0,0); 54 lcd.print("Testing card,"); 55 lcd.setCursor(0,1); 56 lcd.print("Please wait..."); 57 delay(2000); 58 pinMode(10, OUTPUT); 59 clear(); 60 int y = 1; 61 while(!SD.begin(4)){ 62 lcd.print("No card in drive..."); 63 lcd.setCursor(0,1); 64 lcd.print("Insert card"); 65 lcd.setCursor(0,0); 66 }clear(); 67 lcd.print("Card in drive,"); 68 lcd.setCursor(0,1); 69 lcd.print("Please wait..."); 70 71 delay(2000); 72 clear(); 73 root = SD.open("/"); 74 delay(1000); 75 printDirectory(root, 0); 76 clear(); 77 lcd.print("Please remove"); 78 lcd.setCursor(0,1); 79 lcd.print("card from drive."); 80 delay(5000); 81}
Comments
Only logged in users can leave comments