Last active
February 28, 2017 08:16
-
-
Save daz/d8def596f6e513ce118f79fa8f1ad2a7 to your computer and use it in GitHub Desktop.
Arduino UNO Data Logger Shield example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This isn't needed with official Arduino app | |
#include <SPI.h> | |
#include <SD.h> | |
File file; | |
void setup() { | |
Serial.begin(9600); | |
delay(50); | |
pinMode(4, OUTPUT); | |
if (!SD.begin()) { | |
Serial.println("Initialization failed"); | |
return; | |
} | |
// Write to SD card | |
file = SD.open("test2.txt", FILE_WRITE); | |
if (file) { | |
file.println("Hello Test 3!"); | |
file.close(); | |
} else { | |
Serial.println("Error opening test.txt"); | |
} | |
// Read from SD card | |
file = SD.open("test2.txt"); | |
if (file) { | |
while (file.available()) { | |
Serial.write(file.read()); | |
} | |
file.close(); | |
} else { | |
Serial.println("Error opening test.txt"); | |
} | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment