Sketch that reading data from SD Card

I intend to make a sketch for blinking LED in order that number of milliseconds for delay is being read directly from SD card.

Is it even possible?

I tried to google something that could lead me in the right direction but I only find projects that describe reading and logging the data to SD card.

I hope I explained it good enough.

My plan is to be able to change behaviour of the LED without uploading new sketch to Arduino but changing "parameter" in file stored on SD Card


I made a text file in notepad, put an interval of 999 in there. Sketch below (based on standard example dumpfile) reads file in setup() and uses parseInt() to store the value as the blinkInterval.

Dummy blink interval: 50, should change below
Initializing SD card...card initialized.
Blink interval from SD card: 999
// read led's delay from an sd card

  The circuit:
   SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)

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

const int chipSelect = 4;
int blinkInterval = 50; //just a dummy to see that SD card is read properly
unsigned long previousMillis;
bool ledState;

void setup()
  // Open serial communications and wait for port to open:
  pinMode(2, OUTPUT);
  Serial.print("Dummy blink interval: ");
  Serial.println(", should change below");
  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 ="blink999.txt");

  // if the file is available, read from it:
  if (dataFile)
    blinkInterval = dataFile.parseInt();
  // if the file isn't open, pop up an error:
    Serial.println("error opening file");
  Serial.print("Blink interval from SD card: ");

void loop()
  if (millis() - previousMillis >= (unsigned long) blinkInterval)
    previousMillis = millis();
    ledState = !ledState;
    digitalWrite(2, ledState);

Thanks guys.
I intend to use solutions as on the attached picture.
For some practical reasons, I would like to have a little more expensive solutions with USB adapter

Would it cause me any problem?
Is there another good reason to use SD shield without USB-adapter involved?

!(http://<a target=)