daily pastebin goal
74%
SHARE
TWEET

Untitled

a guest Aug 12th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int CS_PIN = 4;
  2.  
  3. File file;
  4.  
  5. void setup()
  6. {
  7.  
  8.   Serial.begin(9600);
  9.  
  10.   pinMode(10, OUTPUT);
  11.   digitalWrite(10, HIGH);
  12.  
  13.   Serial.print("Initializing SD card...");
  14.  
  15.   if (!SD.begin(CS_PIN)) {
  16.     Serial.println("Card failed, or not present");
  17.     return;
  18.   }
  19.   Serial.println("card initialized.");
  20.  
  21.  
  22. }
  23.  
  24. void loop() {
  25.  
  26.   String dataString = "TEST";
  27.  
  28.   File dataFile = SD.open("datalog.txt");
  29.  
  30.   if (dataFile) {
  31.     dataFile.println(dataString);
  32.     dataFile.close();
  33.     Serial.println(dataString);
  34.   } else {
  35.     Serial.println("error opening datalog.txt");
  36.   }
  37.  
  38.   delay(1000);
  39.  
  40. }
  41.    
  42. SD.open("file.txt", O_RDWR | O_APPEND);
  43.  
  44. SD.open("file.txt", O_RDWR | O_CREAT);
RAW Paste Data
Top