#include <SD.h>
String data_string = "Hello";
int CS_pin = 10;
float refresh_rate = 5000.0;
void setup()
{
Serial.begin(9600);
Serial.println("Initialising card");
pinMode(CS_pin, OUTPUT);
// put your setup code here, to run once:
if (!SD.begin(CS_pin))
{
Serial.println("Card failure");
return;
}
Serial.println("Card ready");
}
void loop()
{
File log_file = SD.open("LOG.txt", FILE_WRITE);
if (log_file){
log_file.println(data_string);
log_file.close();
Serial.println(data_string);
} else {
Serial.println("Couldn't open the file");
}
delay(refresh_rate);
// put your main code here, to run repeatedly:
}