#include <SPI.h>
#include <SD.h>

// SDcard variables
const int chipSelect = D8;

void setup () {
//Communication Setup
  Serial.begin(57600);
  Serial.print("Initializing SD card...");

//SDcard Setup
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
}

void loop () {
//SDCARD Part
    File dataFile = SD.open("datalog.txt", FILE_WRITE);
  // if the file is available, write to it:
  if (dataFile) {
    dataFile.print("toto");
    Serial.println("toto");
    dataFile.println();
    dataFile.close();
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.csv");
  }
  delay(10000); //10secondes
}
