1
0
Fork 0
beerbox/beerbox.ino

58 lines
1.1 KiB
C++

#include <SPI.h>
#include <SD.h>
File myFile;
const int chipSelect = 53;
void setup() {
Serial.begin(115200);
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(SS, OUTPUT);
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
check_for_file("p001", "per");
}
void loop() {
}//end loop
void check_for_file(String filename, String extension){
String str = filename + '.' + extension;
char* buf = NULL;
str.toCharArray(buf, str.length() + 1);
if (SD.exists("p001.per")) {
Serial.println(str + " exists.");
}
else {
Serial.println(str + " doesn't exist.");
}
}