不支援NTFS
腳位接法:
CS Pin10 SCK Pin13 MOSI Pin11 MISO Pin12 VCC 5V GBD GND執行結果:
程式碼:
/*
Name: Test2.ino
Created: 2017/3/3 下午 10:33:13
Author: C.Y.Fang
*/
#include <SD.h>
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(9600);
while (!SD.begin()) {
Serial.println("SD Card error!!");
delay(1000);
}
}
// the loop function runs over and over again until power down or reset
void loop() {
static int i = 0;
char s2n[15];
itoa(i, s2n, 10);
strcat(s2n, ".txt");
File file = SD.open(s2n, O_APPEND | O_WRITE | O_CREAT | O_TRUNC);
if (file) {
file.write("Hi");
file.flush();
file.close();
Serial.println("Text save done");
}
else {
Serial.println("Can't create file");
}
i++;
delay(1000);
}