Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <SD.h>
- const int chipSelect = 4;
- void setup() {
- // Open serial communications and wait for port to open:
- Serial.begin(9600);
- while (!Serial) {
- ; // wait for serial port to connect. Needed for native USB port only
- }
- Serial.print("Initializing SD card...");
- // 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:
- while (1);
- }
- Serial.println("card initialized.");
- File dataFile = SD.open("datalog.txt");
- if (dataFile) {
- while (dataFile.available()) {
- Serial.write(dataFile.read());
- }
- dataFile.close();
- } else {
- Serial.println("error opening datalog.txt");
- }
- }
- void loop() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement